views:

72

answers:

1

We have a C# application that instantiates the web browser control and navigates it to a few pages. Our application is definitely marked as STA, and I have no problems building/running the application in both my dev environment, and across all our test machines.

But another developer takes the same code, same version of Visual studio, and gets a run time exception stating that the web browser control cannot be instantiated because the current thread is not in a single-threaded apartment.

Anyone run into this previously?

A: 

STA is a per-thread attribute. Are you sure that the thread that is displaying the web browser is STA?

To make a thread STA, call the SetApartmentState method before starting the thread. (To make the initial thread STA, use the STAThreadAttribute, which I assume you're using).

For a more specific answer, please post more details.

SLaks