Groups | Blog | Home
all groups > dotnet clr > november 2007 >

dotnet clr : Experience hosting the CLR from native c++ ?


Dave Farquharson
11/19/2007 10:23:30 AM
Hello,

I am trying to find good information on hosting the CLR from my native c++
program. I'm successfully using CorBindToRuntimeEx to host the CLR and
executing functions in a test CLR assembly using ExecuteInDefaultAppDomain.
That's all great, but my problem is that the execute function seems rather
limited. It accepts a string argument and returns an int, and that's it.

So my question is, how can more information about state be passed back and
forth between the assembly and the hosting program? I've exercised my search
engine pretty heavily looking for examples and I keep thinking, there must
be a way to share data! Anyone successfully done this or have info about it?

Thanks in advance,

-Dave

Chris Mullins [MVP - C#]
11/19/2007 10:41:44 AM
There's a book out that goes into great detail on hosting the CLR:

"Customizing the Microsoft® .NET Framework Common Language Runtime"
http://www.microsoft.com/mspress/books/6895.aspx

--
Chris Mullins


[quoted text, click to view]

Dave Farquharson
11/19/2007 10:52:22 AM
Hi Chris,

Thank you for your reply. Interesting you brought up this book; I ordered it
on Friday and should get it tomorrow, unless UPS fails me :) Thought I'd
take a crack on getting info today though while I wait, on this part of the
subject anyway.

Thanks again,

-Dave


[quoted text, click to view]

Keith Hall
12/2/2007 7:31:56 PM
Hello Dave,

Have you yet looked at defining "#pragma managed" and "#pragma unmanaged" sections of code in C++? You can use these to generate a "mixed-mode" DLL which you can then load from C++.

This approach seems to work fine, although apparently NOT when the calling C++ is in a native lib loaded by Java JNI. Am trying to find out why...

Regards,

Keith

EggHeadCafe - .NET Developer Portal of Choice
Dave Farquharson
12/3/2007 10:09:52 AM
Hello Keith and thanks for the message.

No, I have not tried that yet. I did get Steven Pratschner's book on CLR
customization, and it's a valuable reference for anyone interested in
hosting the CLR and creating app domains. I have things working almost like
I want, the last piece being communication back to the native host from the
managed assemblies. I will probably take a look at the pragmas you mention
though.

Thanks again!

-Dave

[quoted text, click to view]

AddThis Social Bookmark Button