Ok,

Here we go :-)

Let me start by shooting you down.

IF your interfaces are defined in C++, and IF you r application is a
managed C++ application (i.e. /CLR switch, the classes can still be
unmanaged), why use COM? Just use the classes :-) You can mix them as
you want - there is a template around for holding references to a
garbage collected class from within an unmanaged one.

Otherwise:
If you HAVE to use this outside the managed worls and in C++ (like in an
ATL application):
(a) export the Typelib from the C# file
(b) import it into C++ :-)

COM support is pretty huge in C++7 by now.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)



-----Original Message-----
From: Axel Heitland [mailto:[EMAIL PROTECTED]] 
Sent: Donnerstag, 25. April 2002 00:17
To: [EMAIL PROTECTED]
Subject: [DOTNET] How to expose an interface to unmanaged C++ via
managed C++


Certainly this has been asked before, but I can't find the answer:

I have a C# class implementing some com-visible interfaces and I want to
use these interfaces inside a c++ application ( partly managed, partly
unmanaged). 

I know that I need to assign the ComVisible and Guid attributes to me c#
interfaces.

The call chain is 
        c# class (implements interfaces) 
        -> c++ managed class (receiving the interface ptr as a
parameter) 
        -> c++ unmanaged (receiving the interface ptr as a parameter)

The first transition c# -> managed c++ works nicely, but what do I need
to do to convert the managed interface to the required COM interface in
the last step.

I expect that I need to generate some header files and to somehow
convert my .NET interface to the COM interface.

Any pointers?!

My regards
        Axel

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to