calling C# com object from C++ using STL RRS feed

  • Question

  •  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?

    Monday, November 17, 2008 2:51 PM


  • Hello,

    This forum is to support Interoperability questions on the Open Protocols Specifications. I would suggest that you post your question to a more suitable forum like:

    Visual C# General
    General discussion and questions regarding Visual C# -- including best practices on developing with C# in VS, documentation, setup, and samples.


    John Dunning
    Senior Escalation Engineer Microsoft Corporation

    • Marked as answer by Chris Mullaney Thursday, November 20, 2008 5:28 PM
    Monday, November 17, 2008 4:55 PM