Please help use ATL COM DLL method in C# application
in ATLLib.idl
...
interface IATLLibMain : IUnknown{
[helpstring("method hello")] HRESULT hello([out,retval] BSTR* res);
};
...
in ATLLibMain.cpp (ATL SimpleObject Class)
STDMETHODIMP CATLLibMain::hello(BSTR* res)
{
*res = SysAllocString(L"Hello world!!!");
return S_OK;
}
I have compiled and registered COM. In C# project, added reference to ATLLib.dll and trying call method like this
IATLLibMain atllib = new ATLLibMainClass();
Console.WriteLine(atllib.hello());
and VS gives error
An unhandled exception of type
System.Runtime.InteropServices.COMExceptionoccurred in ATLLibTest.exe.Retrieving the COM class factory for component with CLSID {...} failed due to the following error 80040154.
on line
IATLLibMain atllib = new ATLLibMainClass();
Please show any project sample that use ATL DLL in C# application or help fix this error? Thanks...
Retrieving the COM class factory for component with CLSID {...} failed due to the following error 80040154.on lineIATLLibMain atllib = new ATLLibMainClass();- Erik Kianu0x80040154error (REGDB_E_CLASSNOTREG) tells your ATL DLL has the class in question on type library, but implementation is somehow incorrect: no the interface you quoted, but the whole coclass hosting. You have not yet shown the code on the question, which is wrong. - Roman R.