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, GetApartmentState still says MTA. 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.
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).