Powershell STA watin

Posted by Mike Koerner on Geeks with Blogs See other posts from Geeks with Blogs or by Mike Koerner
Published on Thu, 10 Jun 2010 16:53:09 GMT Indexed on 2010/06/10 17:13 UTC
Read the original article Hit count: 598

Filed under:

Wow, two posts on the same day.

I was working on a quick DLL project to do some web scripting using the awsome power of Watin.  In the past I use to create a vbscript as the test handler to call the DLL but lately I got a Powershell bug to call .NET DLLs.

When I tried to debug the Watin call I received:

The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.

I couldn't find a quick google answer to powershell apartmentstate .  Apparently you can set the powershell apartment state by the command line -STA. 

http://technet.microsoft.com/en-us/library/dd315276.aspx

I've found that the powershell documentation and examples is lacking compared to the Microsoft support I've come to expect.  Why is the Powershell v2.0 in C:\WINDOWS\SYSTEM32\windowspowershell\v1.0 ?

© Geeks with Blogs or respective owner