Known issues with "profile" NGEN Images

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

Where <version> is the CLR version in following format: v<number>.<number>.<number> (for example v2.0.50727, v4.0.30319 etc.)

See also:

Related issue in our tracker: DCVR-3090.

Please sign in to leave a comment.

Have more questions?

Submit a request