By default (at least on my computer, running Windows 7), CLR Profiler 2 won’t work with new XNA apps since they utilize the new .NET framework. It looks like it’s working when you try it, but when it shows the final statistics window it’s empty. Fortunately, it’s possible to enable support using the new profiler compatibility settings functionality, which for this case involves simply setting the COMPLUS_ProfAPI_ProfilerCompatibilitySetting environment variable before running CLR Profiler.
Here’s what I did:
Create a batch file called start_clr_profiler.bat with this content, save it in Documents or wherever:
c: cd "program files (x86)clrprofilerbinariesx86 set COMPLUS_ProfAPI_ProfilerCompatibilitySetting=EnableV2Profiler clrprofiler
It goes without saying that you’ll need to change the drive and path to where you have CLR Profiler installed.
Once you have this file, create a shortcut to it on your desktop. Right click on the shortcut, select Properties, click the Advanced button and check “Run as Administrator”. Click OK a couple of times, and you’re good to go. Just start the profiler with the batch file and the environment variable will be set, and the profiling magic will happen.
You could also set that environment variable at the user or machine level so it’s set all the time, but I don’t know what ramifications that has so prefer setting it just when needed. Happy garbage collecting!