Groups | Blog | Home
all groups > c# > july 2004 >

c# : Importing a VC++ class into a C# program


dominicjoseph NO[at]SPAM rediffmail.com
7/5/2004 11:17:45 PM
Hi

I had a couple of questions:

1.)I am trying to invoke member functions of a class which is coded in
VC++ from a UI that is coded in C#. Firstly, if I am not mistaken I
think this can be done only if the exposed classes are managed. I am
totally new to this. So can someone give some pointers or maybe some
URLs to links on how this can be done - that is how to firstly be
able to export the classes and also how to make them managed/write
managed wrappers for the class.

2.)Once the VC++ coding is done, how do I invoke the member functions?
How do I instantiate an object of the VC++ classes in the C# code. It
would be great if someone could post some links to good articles that
deal with this.

Willy Denoyette [MVP]
7/6/2004 1:38:57 PM
1) You can't directly expose a native interface to managed code, your only
option is to use "Managed Extentions C++" or VS2005's C++/CLI to wrap a
managed reference class around your native class and populate it with stub
methods that invoke the associated native methods.
2) Invoking the methods is done by simply invoking the stubs.

Willy.


[quoted text, click to view]

AddThis Social Bookmark Button