I need to dynamically load and call .NET assembly from native
application, written in C++.
I'm trying to do this by creating a (managed) module, written in C++/
CLI, whose header can be #included from native code like normal C++
header, and whose .cpp file uses C++/CLI to actually load and
call .NET assembly.
It kind of works right now, but not exactly how I want it to. Ideally,
I want to have something like a C++ wrapper class, which hides behing
its public interface all .NET stuff. In particular, I want the
lifetime of this wrapper to correspond to the time the .NET assembly
is loaded and accessible. The trouble is, a C++ class cannot contain
handles to any .NET objects. I cannot even create a global or static
handle. Right now evey time I need to call the assembly, I need to
load it. How to overcome this limitation?
I suspect I can wrap all .NET stuff in COM, but ideally I'd like to
stay away from (directly) calling COM and use C++/CLI instead.
Sheng Jiang[MVP] - 29 Jun 2007 20:30 GMT
>The trouble is, a C++ class cannot contain handles to any .NET objects.
This is not true, you can search for "How to: Declare Handles in Native
Types" in MSDN.

Signature
Sheng Jiang
Microsoft MVP in VC++
> I need to dynamically load and call .NET assembly from native
> application, written in C++.
[quoted text clipped - 15 lines]
> I suspect I can wrap all .NET stuff in COM, but ideally I'd like to
> stay away from (directly) calling COM and use C++/CLI instead.
Ben Voigt [C++ MVP] - 29 Jun 2007 22:10 GMT
> >The trouble is, a C++ class cannot contain handles to any .NET objects.
> This is not true, you can search for "How to: Declare Handles in Native
> Types" in MSDN.
or the documentation for gcroot<T>
>> I need to dynamically load and call .NET assembly from native
>> application, written in C++.
[quoted text clipped - 15 lines]
>> I suspect I can wrap all .NET stuff in COM, but ideally I'd like to
>> stay away from (directly) calling COM and use C++/CLI instead.