The first thing that needs to happen when writing a custom CLR host is to load and initialize the CLR. This happens through a small piece of code that takes a version and other startup information and starts the CLR. This code is known as a “shim” and it is implemented in a file called mscoree.dll. On startup, a process will get a pointer to an interface in this shim and through that interface initialize and start the CLR.
To get an interface to this shim, call CorBindToRuntimeEx. Listing C.1 shows how to make a call to this function. The complete source that is associated with this listing and the following code snippets are available in the CustomCLR directory for this Appendix.