debuggingasp.net-core.net-coreassembliescorflags

Debugging of assemblies with CorFlags ILLibrary flag set


I've tried to debug some ASP.NET Core app. Although I've set the COMPLUS_ZapDisable environment variable to 1 and checked 'Suppress JIT optimization on module load' in Visual Studio, the code in several framework assemblies was hard to debug because it was optimized.

Investigating further I found that those assemblies have the CorFlags.ILLibrary flag set. Those assemblies seem to have precompiled code embedded. Looking at the disassembly view I can see that this precompiled code is indeed being executed.

I didn't find any documentation about this feature. It behaves similar to an NGen-ed assembly where the native code is not in a separate .ni.dll file but embedded in the original assembly.

Does anybody know how to create such an assembly and how to disable the use of the precomiled code while debugging?

Thanks!


Solution

  • I finally found an answer for this:

    .NET Core uses a new precompilation method called Ready2Run. Assemblies are precompiled using CrossGen. The resulting assemblies have the CorFlags.ILLibrary flag set.

    Usage of the precompiled code during runtime can be prevented by setting the COMPlus_ReadyToRun environment variable to 0.

    Probably it's best to also set the COMPlus_TieredCompilation environment variable to 0 (see here and here).