Ok, you’ve installed VS 2010 beta 1, along with .NET FX 4.0 beta 1, and you’re wondering–can you run your profiler against this new .NET framework without recompiling the profiler?
Yes, you can! Though not by default. Although CLR V4 is much more compatible with CLR V2 than CLR V2 was with CLR V1.1, there are still some differences that can mess with your profiler’s mind. So by default, the CLR V4 runtime refuses to activate V2 profilers. If you try, you’ll see that the CLR will LoadLibrary the profiler, use the class factory to generate an instance of the callback object, try to QI for the new ICorProfilerCallback3, and then when that fails, the CLR will release the callback object and log an event to the event log explaining that you need to set COMPLUS_ProfAPI_ProfilerCompatibilitySetting appropriately as your way of "opting in" to running the older profiler binary against the newer CLR. This message is meant for your users, as a way of telling them that the profiler vendor (you) may not yet have tested the profiler against CLR V4.
So, how to use COMPLUS_ProfAPI_ProfilerCompatibilitySetting? Set it to one of the following 3 values:
- It enables the V2 profiler to be activated by V4 CLR.
- DisableV2Profiler (default)
- V4 CLR refuses to activate the V2 profiler, and logs an event to the event log.
- V4 CLR does not load the profiler, regardless of the profiler’s version. This is useful for preventing problems in certain in-process side-by-side CLR scenarios. More on that in an upcoming post.