When using a reg-free COM DLL (isolated = true) in a non-UI thread, I get "unable to cast COM object of type". This is not the case if the DLL is called in the UI thread. However, in my case, I have some pretty resource intensive calls, is there any way around this?
Asked
Active
Viewed 143 times
2
-
What COM apartment models are supported by the types declared in the library? For those types that depend on 'Single', it isn't possible to get around this other than to use your initial thread (typically the UI thread). – meklarian Jun 22 '11 at 01:51
-
1Did you try setting the apartment state of the worker thread to STA? – Brian Gideon Jun 22 '11 at 01:55
-
I think it is a manifest issue. – tofutim Jun 22 '11 at 03:10
-
Have you tried creating a second UI thread? (Yes -- you can do this: http://eprystupa.wordpress.com/2008/07/28/running-wpf-application-with-multiple-ui-threads/ ) – Ed Bayiates Jun 22 '11 at 06:28
1 Answers
0
The best solution to get around this is by invoking the calls to the com in the main thread, even if you were on another method. you can accomplish this by Implement ISynchonizeInvoke in the classes that communicating with the com, check this.

Community
- 1
- 1

Jalal Said
- 15,906
- 7
- 45
- 68