Hi I need to download a file from a site with forms authentication and further processing the text file with Integration Services.
For the file download I choose to use WATIN, So I imported the Watin library and scripted the browser steps. However when I try to run the code I get an Exception with this Message.
The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.
all this using the (with the method attribute)
If I try to use this line of code to set it to STA
System.Threading.Thread.CurrentThread.SetApartmentState(Threading.ApartmentState.STA)
I get this exception
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Failed to set the specified COM apartment state. at System.Threading.Thread.SetApartmentState(ApartmentState state)
How do I change the SSIS script task to use this Single-Threaded apartment?