Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Writing COM accesible objects in Managed C++

Writing COM accesible objects in Managed C++

Scheduled Pinned Locked Moved Managed C++/CLI
c++comtutorialquestion
3 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tlemoine
    wrote on last edited by
    #1

    Im trying to create a Managed C++ object that will be accessible both from Managed Code, as well as through a standard COM interface. I have written the component and have no problems using it from JScript, so I moved on to attempting use through standard COM from Win32 App. When I export the type library from the assembly, it contains the definitions for the classes but not the interfaces?? For example if I built the following overly simplified managed code into an assembly #include "stdafx.h" #using using namespace System; using namespace System::Reflection; using namespace System::Runtime::InteropServices; [assembly:AssemblyKeyFileAttribute("ComponentTest.snk")]; namespace TestNM { __gc __interface ITestComp { int GetNumber(); void SetNumber(int num); }; __gc public class MyTestComp : public ITestComp { public: MyTestComp() { m_iNumber = 0; } ~MyTestComp() {}; int GetNumber() {return m_iNumber; } void SetNumber(int num) { m_iNumber = num; } private: int m_iNumber; }; } Then export the type library, and open with oleview, the definition of "ITestComp" interface is no where to be found, in fact it says MyTestComp is an interface??? Anyone have any ideas? Thanks!

    J 1 Reply Last reply
    0
    • T tlemoine

      Im trying to create a Managed C++ object that will be accessible both from Managed Code, as well as through a standard COM interface. I have written the component and have no problems using it from JScript, so I moved on to attempting use through standard COM from Win32 App. When I export the type library from the assembly, it contains the definitions for the classes but not the interfaces?? For example if I built the following overly simplified managed code into an assembly #include "stdafx.h" #using using namespace System; using namespace System::Reflection; using namespace System::Runtime::InteropServices; [assembly:AssemblyKeyFileAttribute("ComponentTest.snk")]; namespace TestNM { __gc __interface ITestComp { int GetNumber(); void SetNumber(int num); }; __gc public class MyTestComp : public ITestComp { public: MyTestComp() { m_iNumber = 0; } ~MyTestComp() {}; int GetNumber() {return m_iNumber; } void SetNumber(int num) { m_iNumber = num; } private: int m_iNumber; }; } Then export the type library, and open with oleview, the definition of "ITestComp" interface is no where to be found, in fact it says MyTestComp is an interface??? Anyone have any ideas? Thanks!

      J Offline
      J Offline
      Jonathan Darka
      wrote on last edited by
      #2

      Hi tlemoine, You are right because MyTestComp IS an interface too!, what you need to do is tell the type library exporter that it shouldn't create a type library section for MyTestComp. You need to add the following attribute... can't remember the exact syntax for MC++ though. Regards, Dark Angel

      J 1 Reply Last reply
      0
      • J Jonathan Darka

        Hi tlemoine, You are right because MyTestComp IS an interface too!, what you need to do is tell the type library exporter that it shouldn't create a type library section for MyTestComp. You need to add the following attribute... can't remember the exact syntax for MC++ though. Regards, Dark Angel

        J Offline
        J Offline
        Jonathan Darka
        wrote on last edited by
        #3

        Here is the attribute again.... but visible this time <ClassInterface(ClassInterfaceType.None)>

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups