QueryInterface failed Unspecified error 0x80004005 (E_FAIL) RRS feed

  • Question

  • I am attempting to use a C# application to interact with COM+. I am able to create an instance of the object, but when I attempt to use an interface I get the following: QueryInterface failed Unspecified error 0x80004005 (E_FAIL).

    I will attempt to outline the steps that I have used to get to this point.

    First I took an IDL file that contained a bunch of interfaces. Next I used VS2010 to build a type library file. From here, I used tlbimp.exe to create a primary interop dll. Because I was using a bool type in my IDL and it did not properly convert into my tlb file, I had to disassemble the dll and convert one of the method signatures to use type bool. Next I reassembled the dll and started using it in my C# program that actually defines the interfaces.

    I next created a C# service that defined all of the interfaces after referencing the interop dll. The resulting dll then got registered using regsvcs. Using OleView I am able to create an instance of my COM+ object.

    Everything appears to be working correctly up to this point. I have examined my registry and all the entries look correct. When I create a test application to start using these newly defined methods, I start having issues. I am able to create an instance of my interface, but I am unable to query the interface.

    When I call GetTypeFromProgID and then GetInterfaces, I see IRemoteDispatch and IManagedObject as opposed to the interfaces inside my class. I think that may be why I have an unknown error, but I am not sure if this should be my expected results. Any help would be greatly appreciated.



    Robert W. Crockett
    Monday, January 10, 2011 12:34 AM



    From my understanding of your question, the calling hierarchy might be: ('-->' means 'invoke by')


    COMServer1.dll (COM service) --> Interop.ComServer1.dll --> C# dll wrapper--> another application (C++? C#?)


    Why we need a C# dll wrapper between "Interop.ComServer1.dll" and "another application"? if the "another application" is a native (C++) application, you can invoke the COM server directly; if the "another application" is a C# application, you may add reference to  Interop.ComServer1.dll.

    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by eryang Monday, January 17, 2011 7:40 AM
    Thursday, January 13, 2011 4:40 AM