views:

146

answers:

1
A: 

Just in case this helps someone else;

It seems my issue was the result of a threading issue;

I noticed the C# winform apps I had created were automatically set to run on a single 'ApartmentState' thread ([STAThread]).

Whereas the console applications & class library thread state and management hadn't been defined within the project and was being handled with the default .NET config.

To get this to work; In the console application; I just added the [STAThread] tag on the line above my Main method call.

In the class library; I defined a thread for the function referencing the IMANxxx.dll and set ApartmentState e.g.

Thread t = new Thread(new ThreadStart(PerformSearchAndMove)); t.SetApartmentState(ApartmentState.STA); t.Start();

In both cases ensuring single 'ApartmentState' thread was implemented set would resolve the issue.