"Joel Lucsy" <jj*****@usol.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
Willy Denoyette [MVP] wrote: "Joel Lucsy" <jj*****@usol.com> wrote in message
news:eU*************@TK2MSFTNGP10.phx.gbl...
I believe there is a third option, hosting the CLR runtime. This involves
using COM to "load" the CLR runtime, but not to have the particular
assemblies "registered" like typical Active-X stuff.
Well not really, when hosting the CLR, you still need to call managed
code through one of the interop layers be it COM or Managed thunks. True,
you don't need an IA in a COM interop scenarion you can dynamically
create a CCW, but it's not a trivial task though.
Willy.
Why would you need a CCW? The host uses COM to instantiate the CLR and
then uses those interfaces to call whichever managed code you want. To
call back into the host you could use P/Invoke just fine without having a
CCW around. Of course this method means you can't use classes defined in
the host, but this may not be a problem as it really depends on what
you're trying to accomplish. I've tested this technique just fine.
--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space
program." -- Larry Niven
Joel,
I 'm not 100% clear on what you mean here. The host instantiates the CLR
using the COM based hosting API's, that's right, but the CLR is unmanaged
code. And then you say; "then uses those interfaces to call whichever
managed code you want."
If you mean by this that you can use the hosting API's to load an assembly
and START executing this managed ( say C#) code by calling it's entry point,
then I agree, but this is not the same thing as a direct call into managed
objects methods from native code. This is simply not possible has you need a
Object reference in order to call managed methods, or you need a CCW that
translates the .NET object model into a COM interface model so that native
COM clients can create instances and call methods through COM interop, or
you need a wrapper class that thunks the native C++ object into a managed
interface.
Willy.