This sample code accompanies the article “Hosting the Common Language Runtime” in the XXX issue of MSDN magazine. While not a complete host, the sample code demonstrates the API’s and the architecture of a typical host as described in the article.
Visual C++ 6.0 and the Beta1 release of the .NET Framework SDK are required to build and run this sample.
This sample host consists of both unmanaged and managed code. The unmanaged code is a VC 6.0 console application called Clrhost. Clrhost loads the CLR into the process, creates the managed hosting code and directs user requests into managed code. The managed portion of the host creates an application domain with domain level security evidence and custom security policy.
To build the unmanaged portion of the sample, open ClrHost.dsw in VC 6.0 and select “Rebuild All”. The Clrhost project assumes the .NET Framework SDK is installed in c:\program files\Microsoft.net\frameworksdk. If your SDK is in a different location, adjust the include directories and libpath in “Project->Settings” accordingly.
To build the managed portion of the sample, type “nmake all” from the mgd directory under ClrHost.
Run clrhost.exe from the Debug directory under Clrhost. You should see the following output:
Unmanaged hosting code
started...
Version 1.0.2204 of the
CLR loaded...
Managed hosting code
successfully created...
Domain properties successfully
initialized...
Domain level evidence
successfully created...
Domain security policy
successfully created..
Domain MyDomain
successfully created...
Domain MyDomain
unloaded...
Done.