I am calling WatiN from a C# windows service. When I invoke WatiN it throws the following exception. The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer
I have tried starting up a thread and setting the apartment state via
mythread.SetApartmentState(ApartmentState.STA)
but that resulted in another error
*Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.*
I also tried adding an attribute to the Service entry point.
static class Program
{
[STAThread]
static void Main()
{
...
Any ideas?