calling C# com object from c++ using ATL

csharp , com , atl Israel
  • 12 years ago
    Hello, I have a C# com object (.net framework 2.0) that I want to call from C++. I tried to import the tlb and create the object using MyNamespace::IMyInterfacePtr pObj; but i got errors about not impelemting queryInterface, AddRef etc. I found out that I should use CComObject (ref: http://support.microsoft.com/kb/181265[^]. So declaring the variable was a success using: CComObject* pObj; Now I am trying to create an instance by using: HRESULT hRes = (CComObject::CreateInstance(&pObj); But I get the following error: c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(2395) : error C2504: 'MyConClass' : base class undefined see reference to class template instantiation 'ATL::CComObject;' being compiled Any ideas what I am doing wrong? thanks!

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Weeks of coding can save you hours of planning.”