0

Hi
I am trying to add FolderBrowserDialog to my ASP.NET page. So i added a reference to using System.Windows.Forms. Now i have placed a button and in button click event i have written code like this .

protected void Button1_Click(object sender, EventArgs e)
    {
        FolderBrowserDialog fbd = new FolderBrowserDialog();
        fbd.ShowDialog();
    }

When i run the application and click on the button i am geeting the following error.

Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.

pls some help me to solve this problem

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Kusno
0

Do as the error says - apply the STAThread attribute to your Main method.

-G Himangi, LogicNP Software [url]http://www.ssware.com[/url] 
Shell MegaPack: GUI Controls For Drop-In Windows Explorer like File/Folder Browsing Functionality (.Net & ActiveX Editions).
EZNamespaceExtensions: Develop namespace extensions rapidly in .Net and MFC/ATL/C++
EZShellExtensions: Develop all shell extensions,explorer bars and BHOs rapidly in .Net & MFC/ATL/C++

Hi
I am trying to add FolderBrowserDialog to my ASP.NET page. So i added a reference to using System.Windows.Forms. Now i have placed a button and in button click event i have written code like this .

protected void Button1_Click(object sender, EventArgs e)
    {
        FolderBrowserDialog fbd = new FolderBrowserDialog();
        fbd.ShowDialog();
    }

When i run the application and click on the button i am geeting the following error.

Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.

pls some help me to solve this problem

Edited by mike_2000_17: Fixed formatting

0

As I know, FolderBrowserDialog only runs in Windows Desktop not in ASP.NET.
You may use third-party control.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.