Short description:
Some tools (e.g. BugAid) for performance reasons create a special kind of NGEN images (“Profile” images) for some of the .NET framework assemblies.
Due to a bug in the Microsoft .NET Profiling API, this leads to incorrect behaviour of the instrumenting profilers.
In case of dotCover and dotTrace you may get the following exception:
System.MissingMethodException: Method not found: 'Void System.Runtime.Versioning.TargetFrameworkAttribute.JetBrains_Profiler_Core_Instrumentation_Begin(UIntPtr ByRef)
Full description:
When an IL instrumenting profiler detects that an NGEN /Profile assembly exists, this assembly is immediately loaded, even though in fact it cannot be instrumented.
According to Microsoft, this issue will be fixed in their next release: there will be a flag in the Profiling API that the instrumenting profiler can turn on, which will cause it to ignore the existance of NGEN /Profile assemblies and go back to JITing.
Workaround:
Removing "profile" NGEN images can help to get a quick fix for the issue.
This can be performed using the following commands:
- for Windows 32-bit:
%WinDir%\Microsoft.NET\Framework\<version>\ngen.exe uninstall * /profile
- for Windows 64-bit:
%WinDir%\Microsoft.NET\Framework\<version>\ngen.exe uninstall * /profile
%WinDir%\Microsoft.NET\Framework64\<version>\ngen.exe uninstall * /profile
See also:
Related issue in our tracker: DCVR-3090