Changes to the CLR Hosting Tools library in 6.3

One of my clients has recently required .Net 4.0 hosting support and so most of the changes in the CLR Hosting Tools library in 6.3 have been driven by them.

The main new feature is the optional use of the .Net 4.0 hosting API. This allows us to host .Net 4.0 as well as earlier CLRs and also allows us to host multiple different CLRs in a single process. The new hosting API is supported via the CCLRHostFactory object which uses the CCLRMetaHost and CCLRRuntimes objects to present a consistent interface to both the .Net 4.0 and .Net 2.0 hosting APIs. There’s some cruftiness inside the host factory so that you can be a bit vague about exactly which version of the CLR that you want. Or you can be precise…

The CCLRMetaHost class existed in v6.2 but this time around it’s more flexible. In 6.2 we required that you had .Net 4.0 installed if you wanted to allow your server the chance at loading it. Now we dynamically link with the new API so that the same compiled server can run on a box with or without .Net 4.0 and can be configured to use .Net 4.0 if it’s present and fall back to 2.0 if it’s not.

We also expose the host and CLR policy manager objects so that you can make your hosting a bit more robust by setting error escalation policies.

There are two new managed hosting examples. One which demonstrates the CLRHostFactory and .Net 4.0 hosting and one that shows how to build a server that provides full shadow copy and automatic application restart functionality; see here and here for more details.