Live Chat Icon For mobile
Live Chat Icon

Why do I have to use the STAThread attribute for my main method in my app.?

Platform: WinForms| Category: Threading

While the STAThread is required (as the documentation states) and pertinent only to applications that use COM interop, 1.0 version of the .Net framework has some bugs that makes it necessary for you to specify the STAThread attribute:

1) Ole Drag Drop will not work without STA. You can check this by turning on drag and drop in a form and try to run it.

2) Invoking a method in a type using Reflection will not work either.

These bugs have however been resolved in the 1.1 version of the framework (Everett). Which means you then do not have to specify this attribute for your main method.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.