VB.NET-APP: How to set Single Threaded Apartment model?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mike1reynolds
    New Member
    • Apr 2008
    • 8

    VB.NET-APP: How to set Single Threaded Apartment model?

    While my project is in an STA state, when I added a class with no form it is executing in an MTA state. I can't find any reference to MTA or STA anywhere in the entire solution. How do I set a class to run in STA rather than MTA mode?

    When I try to instantiate a form object 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, GetApartmentSta te still says MTA. From the main form GetApartmentSta te 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.
Working...