CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2002
    Location
    Moscow
    Posts
    2

    Unhappy Can't use COM object from another thread

    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?

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    may be that's the threading model issue.

    what are you casting ? by the way...

    Paresh

  3. #3
    Join Date
    Jul 2002
    Location
    .NET 2.0/.NET 3.0/.NET 3.5 VS2005/VS2008
    Posts
    284
    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
    WM.

    What about weapons of mass construction?

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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

    Paresh

  5. #5
    Join Date
    Jun 2002
    Location
    Moscow
    Posts
    2

    Unhappy

    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.

  6. #6
    Join Date
    Jul 2002
    Location
    .NET 2.0/.NET 3.0/.NET 3.5 VS2005/VS2008
    Posts
    284
    Euhm yeah, well I will try that too , I post a message here when I have results (good or bad).
    WM.

    What about weapons of mass construction?

  7. #7
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    VALE rA
    did you got the solution around.
    I would be interested in knowing ur problem

    Paresh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured