F
Frank
IDE: Visual Studio 2005
Language: C#
I am making use of an older COM object in a C# project by adding a
reference to it in my project. I have no problems actually making use
of the COM library the same as is done by previous versions of
software written in unmanaged C++. The only difference is that this
time, I am trying to create multiple instances of the objects
available in the COM library via "new" in the same application (in my
case, the COM library gives me serial connectivity to a specialized
piece of hardware, currently multiple instances of a program are run
to connect multiple pieces of hardware, I would like to connect
multiple instances to the same piece of software). I believe I am only
getting references to an already existing instance, and not a wholly
new and separate object.
In doing some research over the past few days I've discovered that
creating new instances of objects available in my COM library from C#
has the underlying effect of calling CoCreateInstance;
http://msdn.microsoft.com/en-us/library/aa645736(VS.71).aspx, see the
first paragraph of "Creating a COM Object". It is my understanding
that CoCreateInstance will not create a wholly new instance of an
object unless one doesn't exist, and gives the caller a reference to
that object. If one exists then it just passes back a reference to the
currently existing. Am I incorrect in my understanding here?
Is there a way to create new and separate instances of the objects in
my COM library from C#? I guess this would be like calling
CoGetClassObject to create separate instances. Does anyone have any
suggestions?
Language: C#
I am making use of an older COM object in a C# project by adding a
reference to it in my project. I have no problems actually making use
of the COM library the same as is done by previous versions of
software written in unmanaged C++. The only difference is that this
time, I am trying to create multiple instances of the objects
available in the COM library via "new" in the same application (in my
case, the COM library gives me serial connectivity to a specialized
piece of hardware, currently multiple instances of a program are run
to connect multiple pieces of hardware, I would like to connect
multiple instances to the same piece of software). I believe I am only
getting references to an already existing instance, and not a wholly
new and separate object.
In doing some research over the past few days I've discovered that
creating new instances of objects available in my COM library from C#
has the underlying effect of calling CoCreateInstance;
http://msdn.microsoft.com/en-us/library/aa645736(VS.71).aspx, see the
first paragraph of "Creating a COM Object". It is my understanding
that CoCreateInstance will not create a wholly new instance of an
object unless one doesn't exist, and gives the caller a reference to
that object. If one exists then it just passes back a reference to the
currently existing. Am I incorrect in my understanding here?
Is there a way to create new and separate instances of the objects in
my COM library from C#? I guess this would be like calling
CoGetClassObject to create separate instances. Does anyone have any
suggestions?