Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set Single Threaded Apartment model

Status
Not open for further replies.

ProtocolPirate

Programmer
Nov 21, 2007
104
US
Somehow my project got into an MTA state, but I can't find a reference to MTA or STA anywhere in the entire solution. How do I set it back to STA?
 
Also, when I try to bring up a dialog box from a class with no form, I get an exception of "control cannot be instantiated because the current thread is not in a single-threaded apartment". When I put <STAThread()> in front of the function that throws the exception, GetApartmentState still says MTA.
 
I just discovered that from the main form GetApartmentState says STA, so somehow the formless class has been switched into an MTA state while the rest of the project is in an STA state.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top