COM interop and imported interface and class names

D

Dan Holmes

When importing a COM component that was written in VB there will be more than one interface/class name created for each
public class. Just a simple activex DLL will create two interfaces and one class in the interop file.

In this case i have a class in a VB6 project named RseComAdapter. When compiled and referenced by VS2005 the object
viewer shows _RseComAdapter (interface), RseComAdapter (interface) and RseComAdapterClass (class).

Does it matter which of those i use in code when declaring or creating? Are they interchangeable?

is

_RseComAdapter rse = new RseComAdapterClass();

the same as

RseComAdapter rse = new RseComAdapterClass();

thanks for any guidance.

danny
 
P

Pavel Minaev

When importing a COM component that was written in VB there will be more than one interface/class name created for each
public class.  Just a simple activex DLL will create two interfaces andone class in the interop file.

In this case i have a class in a VB6 project named RseComAdapter.  Whencompiled and referenced by VS2005 the object
viewer shows _RseComAdapter (interface), RseComAdapter (interface) and RseComAdapterClass (class).

Does it matter which of those i use in code when declaring or creating?  Are they interchangeable?

is

_RseComAdapter rse = new  RseComAdapterClass();

the same as

RseComAdapter rse = new  RseComAdapterClass();

thanks for any guidance.

When in doubt, check for GuidAttribute on those interfaces. If it
matches, then it's the same interface COM-wise, and you can safely use
either one, and, IIRC, cast from one to another if you ever need to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top