Shameel recommended you to use
[STAThread]
. This is not always possible, as your application might require
[MTAThread]
. In this case, here is what you can do: create a separate thread and set its apartment state to
System.Threading.ApartmentState.STA
using
System.Threading.Thread.SetApartmentState
. You can do it in the thread where you create a thread, not in the created thread, and you should do it before the thread is started.
In the body of the new thread, create and use your ActiveX object.
See:
http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.threading.thread.setapartmentstate.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.threading.apartmentstate.aspx[
^].
—SA