COM Interop

  • Thread starter Thread starter Daniel Bello Urizarri
  • Start date Start date
D

Daniel Bello Urizarri

How can i know the order of the methods and properties in a com interface?
And how must marshal the different types?
 
How can i know the order of the methods and properties in a com interface?

You look at the interface declaration in an IDL or header file, or
read the documentation if it lists methods in vtable order.

And how must marshal the different types?

What types, exactly?



Mattias
 
Daniel said:
How can i know the order of the methods and properties in a com interface?
And how must marshal the different types?

Why do you care about the order of methods and properties? Unless.. you
are trying to access them through ids. In which case you can use
ITypeLib and ITypeInfo interfaces (from classic COM days) as long as
they are represented within a typelib and figure that out.

As for the marshalling of different types, you should first consider
creating a RCW and see if that can handle the types correctly. Only if
you need to explicitly marshal specific instances of objects for which
there are no equivalents in .NET that you should consider hand-woven
marhsalling code. In that particular case, check out the interop
services documentation in MSDN.
 
There is an article in the MSDN called "COM INTEROP Part 1: C# Client
Tutorial" with the steps to follow to create coclasses and type interfaces:
(Does not explain what to do with properties)

The following paragraph is the reason for me to be interested in the order
of methods:

"COM interfaces are represented in C# as interfaces with ComImport and Guid
attributes. They cannot include any interfaces in their base interface list,
and they must declare the interface member functions in the order that the
methods appear in the COM interface."


My goal is to create a dll (single one) that uses some COM objects. If I add
a reference, Visual Studio will add an extra dll with the proxy objects and
I don't want two dlls, just one. If there is some article more complete or
more clear....

I want to show the oledb connection dialog, I can show de dialog, and I can
create a Connection object, but when I assign the connection string, and
consult it the value is no right, I thought it was because of the "member
order".
 
Daniel,

You may want to try the tool COMtoNET from from Aurigma
(http://www.aurigma.com). It has the ability to output source code
that you can compile into your project instead of referencing a
separate interop assembly. And reading the code it produces is a good
way to learn how to write your own imported COM interface definitions.



Mattias
 
Back
Top