HighTechTalks DotNet Forums  

Experience hosting the CLR from native c++ ?

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss Experience hosting the CLR from native c++ ? in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Dave Farquharson
 
Posts: n/a

Default Experience hosting the CLR from native c++ ? - 11-19-2007 , 12:23 PM






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



Reply With Quote
  #2  
Old   
Chris Mullins [MVP - C#]
 
Posts: n/a

Default Re: Experience hosting the CLR from native c++ ? - 11-19-2007 , 12:41 PM






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


"Dave Farquharson" <gamerfarquharson (AT) hotmail (DOT) com> wrote

Quote:
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




Reply With Quote
  #3  
Old   
Dave Farquharson
 
Posts: n/a

Default Re: Experience hosting the CLR from native c++ ? - 11-19-2007 , 12:52 PM



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


"Chris Mullins [MVP - C#]" <cmullins (AT) yahoo (DOT) com> wrote

Quote:
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


"Dave Farquharson" <gamerfarquharson (AT) hotmail (DOT) com> wrote in message
news:OzxiImtKIHA.3916 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
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






Reply With Quote
  #4  
Old   
Keith Hall
 
Posts: n/a

Default RE: Experience hosting the CLR from native c++ ? - 12-02-2007 , 09:31 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
http://www.eggheadcafe.com

Reply With Quote
  #5  
Old   
Dave Farquharson
 
Posts: n/a

Default Re: Experience hosting the CLR from native c++ ? - 12-03-2007 , 12:09 PM



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

<Keith Hall> wrote

Quote:
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
http://www.eggheadcafe.com



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.