This problem occurs when you add some active control like web browser.I added web browser in some panel and tried to run the application, it says
"System.Threading.ThreadStateException was unhandled"
Solution:-
So just add [STAThread] above the main function where you instantiate the class.
e.g.(c#)
[STAThread]
static void Main()
{
Application.Run(new Parent_Form());
}
Useful Links:-
Thank you for your information about STAThread. I had pasted something between [STAThread] and Main, and got that silly exception. Now my program works!
ReplyDelete-Scott D.
OMG!!! THANK YOU!! I have been working on a compiler for my own programming language.. And i would get the stupid thread error when i would try to open a dialog box.. Thank you so much.
ReplyDeleteI had [STAThread] but it does not work :(
ReplyDeletewhat should I do ?