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

Recommended Answers

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 …
Jump to Post

All 2 Replies

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.