DCSIMG
Windows Platform Developers User Group meeting - Pavel's Blog
Sign in | Join | Help

Pavel's Blog

Pavel is a software guy that is interested in almost everything
software related... way too much for too little time

Windows Platform Developers User Group meeting

This evening was a WPDUG meeting on CLR hosting and CLR profiling. Thank you all for coming! It was a pleasure to see so many of you there. My session was on CLR hosting, using the new CLR 4 hosting API. This is done using native code (C++) that uses COM for communication between the CLR and the host, both ways.

I showed how to enumerate the installed runtimes, how to load a specific CLR (a new feature of CLR 4 – the ability to host multiple CLRs in a single process), how to create an application domain (all from native code, of course). The interesting parts are the interfaces used to call on the CLR and the host implementations for CLR usage.

 

Picture1

After a ICLRRuntimeInfo interface is obtained, a call to GetInterface allows getting some functionality aspect from the CLR. The most interesting interfaces are ICLRRuntimeHost (new in CLR 4) and ICorRuntimeHost (the old one, but has functionality not available in the new one).

From the ICLRRuntimeHost, you can call GetCLRControl and from there get a management aspect object from the CLR. You can browse the presentation attached to the end of this post and the source code examples. In the other direction, calling ICLRRuntimeHost::SetHostControl allows the host to supply its objects for controlling various aspects of the execution, such as notifications for GC, memory management and more.

 image

In the code sample, one can choose a CLR to work with, and execute some managed executable in some app domain, while at the same time get indications on GC and memory related activities. This is, of course, just the tip of the iceberg.

Comments List

# re: Windows Platform Developers User Group meeting

Published at Wednesday, August 31, 2011 3:39 AM by Vlad Prokudin  

I couldn't see the source code for CLR Hosting Demo application on this page. Is that Ok with it?

Thanks,

# re: Windows Platform Developers User Group meeting

Published at Wednesday, August 31, 2011 9:15 AM by pavely  

You're right, here's a link to the demo ZIP:

blogs.microsoft.co.il/.../entry891205.aspx

# re: Windows Platform Developers User Group meeting

Published at Thursday, September 01, 2011 9:45 AM by Vlad Prokudin  

Thanks!

Leave a Comment

(required) 
(
required
)
 
(optional)
(required) 

Enter the numbers above: