Problem:- An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll
in microsoft visual c++
Solution:-
Just write '[STAThread]' above the main() function to resolve the problem. This code make your program single-threaded apartment (STA) instead of MTA.
Example:-
[STAThread]
int main(){
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew UserForm());
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment