At our current project, we have an application which is deployed using No Touch Deployment. Because of some SEHException we got a few months back, we started our application in a separate thread using a launcher class which contains the Main() method for the application. Recently we added functionality to display HTML pages our application generates, so we added the ActiveX webbrowser (in AxSHDocVw.dll).

Starting an application through IEExec makes that the STAThreadAttribute is ignored. Because of this we received the error "Could not instantiate activex control ‘xxxx-xxx’ because the current thread is not in a single threaded apartment" as soon as we instantiated the webbrowser. Because we start our application in a seperated thread, the solution was simple: set the ApartmentState of the new thread.

Code:
public static void Main()
{
   
Thread thread;
    ThreadStart threadStart;

    threadStart = new ThreadStart(StartMyApplication);
    thread =
new Thread(threadStart);

    thread.ApartmentState = ApartmentState.STA;

    thread.Start();
}