Partager via


Silverlight and CLR enumeration

Jason Zander posted sample code to enumerate all the CLRs (both regulars like 1.0, 1.1, 2.0 and Silverlight 1.1 CLR) in a process. The basic idea is that it sniffs for the presence of the unmanaged dll that implements the runtime (mscorwks.dll, coreclr.dll).

There are some interesting tool implications here.

The basic question is "What version of the runtime (if any) is loaded into a process? " We actually have a public API to answer that, mscoree!GetVersionFromProcess, which was added in .NET 2.0.

However, that question has a fundamental assumption that there's only at most 1 CLR in the process. Silverlight 1.1 allows multiple CLRs to live in a single process side-by-side.  This will have some interesting implications for the tool APIs.  For example, APIs like "GetVersionFromProcess" suddenly lose meaning.  Which CLR would they return? In fact, what do the returned version strings even mean anymore?

Versioning problems always started off simple in 1.0. Back when we just had 1.0 CLR, Jason's app could be written in a few lines of managed code, as demoed with the publish API.  Jason's sample to do this enumeration in a world with multiple major CLR versions and silverlight is ~250 lines. Silverlight 1.1 is still in Alpha, so it's early and we still have a decent runway to iron this out. I'd expect that we'll be adding new tool APIs that encapsulate some of this discovery information, and that much of the functionality in Jason's sample will eventually get included in Mdbg wrappers.