Using my C# DLL in an unmanaged environment  
Author Message
RiotAct





PostPosted: Visual C++ General, Using my C# DLL in an unmanaged environment Top

I hope this is the right forum for this, if not I apologize...

For a reason that I can't say, I had an interface defined in an IDL file that I implemented in C#. I now want to use this DLL in unmanaged C++. It is a requirement for what I am doing, but I know next to nothing about C++...

Each of my implemented classes has a GUID attribute and a ComVisible attribute. The other requirement is that I use the original TLB, but that's as far I got. I created a C++ project and did an #import "MY.tlb" and it compiled. I also registered my C# dll using regasm. Now how do I get access to my classes I read somewhere about using a ProgID, but I am not entirely sure what that is.... Thanks in advance to anyone who can help.



Visual C++14  
 
 
nobugz





PostPosted: Visual C++ General, Using my C# DLL in an unmanaged environment Top

You'll have a pretty steep learning curve ahead of you if you haven't previously done any COM programming in C++. Start by taking a good look at the _com_ptr_t class, the #import statement generates smart pointers for the interfaces defined in the TLB. The CreateInstance() method creates a the COM object.

Moved to C++ General forum.