Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi instances COM object

Tags:

c++

c#

interop

com

I use a C++ written COM object in C#. I just create instance through "new". I need numerous of such objects. But every other "new" doesn't create new instance, but only gives reference on first object. Thats why I have a mess with data. Is it possible to get new instance every time? Or I should realize IClassFactory in my COM to instantiate not singleton? I've made COM with master in VC 2010 with ATL support. And I have a trouble where and how to realize IClassFactory.

like image 911
plax Avatar asked Dec 31 '25 12:12

plax


1 Answers

You need to implement IUnknown, IClassFactory. Depending on what you're doing you may want to implement IDispatch and IErrorInfo as well. It's quite involved so I won't go into the details here. The following three articles should cover pretty much everything that you are after:

  1. Step by Step COM Tutorial
  2. Understanding Classic COM Interoperability With .NET Applications
  3. Fundamentals of ATL COM Objects
like image 86
JamieSee Avatar answered Jan 02 '26 01:01

JamieSee