Click to See Complete Forum and Search --> : Can't use COM object from another thread
Vale RA
January 17th, 2003, 07:28 AM
I create MMC snapin using C#. Everything works fine until I try to access any MMC COM objects from another thread. I get exception which says:
An unhandled exception of type 'System.InvalidCastException' occurred in computernode.dll
Additional information: QueryInterface for interface IConsole2 failed.
What can be done about that?
pareshgh
January 17th, 2003, 12:38 PM
may be that's the threading model issue.
what are you casting ? by the way...
Paresh
WillemM
January 18th, 2003, 12:46 AM
I think you forgot the convert a type from one to another... try to find the line where it gives the error and fix the type casting there :)
pareshgh
January 18th, 2003, 02:36 AM
since he wrote 'from a thread' so i gave idea of - checking theading model. type casting would also be a problem.
check that plz. and return with your answer.
you could also find better solutions at
GotDotNet.com (http://www.gotdotnet.com/Community/MessageBoard/MessageBoard.aspx?ID=6)
Paresh
Vale RA
January 20th, 2003, 01:49 AM
pareshgh
may be that's the threading model issue
Well... I tried it in STA and in MTA, but the result was the same :(
you could also find better solutions at GotDotNet.com
Thank you I'll try that link
WillemM
I think you forgot the convert a type from one to another... try to find the line where it gives the error and fix the type casting there
Well, actually, it was the first thing I've checked about this bug :) The problem is that it works when it is in the main thread, the same code doesn't want to work in another thread.
WillemM
January 20th, 2003, 08:56 AM
Euhm yeah, well I will try that too :D, I post a message here when I have results (good or bad).
pareshgh
February 17th, 2003, 06:08 PM
VALE rA
did you got the solution around.
I would be interested in knowing ur problem
Paresh
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.