Click here to Skip to main content
15,791,356 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have developed ATL COM DLL in visual c++. I register the dll and had added reference to the dll in c++.I try to use c++ COM dll in WCF REST services in c#,but I get the following error:

Unable to cast COM object of type 'System.__ComObject' to interface type 'ProVisionCOMDemoLib.ReadDATFile'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{91820B46-B3FD-41FE-9A75-45A72424F480}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Please help me to solve this error.Please suggest some ways to call c++ com dll in WCF Rest services in c#.

Thanks and Regards

What I have tried:

The following code used to call com c++ dll in WCF rest web services in c#:
object sResult;
ProVisionCOMDemoLib.ReadDATFile objTest = new ProVisionCOMDemoLib.ReadDATFile();
objTest.ReadDATFile(mFileName, out sResult);
Updated 5-Aug-17 8:54am
David 'dex' Schwartz 7-Jun-17 5:42am    
Do you have the C# set up with the correct Reference entry for your DLL?
Are you able to debug the call to QueryInterface in your ReadDATFile object?

Please post the following information.

IDL for the ReadDATFile object.
ReadDATFile header file with class declaration, all interfaces and COM related macro based declarations.
If you have a customer QueryInterface implementation you should post that too.

1 solution

You have some naming issues in your code. Check the naming and GUID of the registered component which is in the registry.

The name and GUID must be unique, but your name sounds like from some sample code. Change it and rebiuld, register. COM is pain in the ass sometimes ;-)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900