Determine if GAC'ed & NGen'ed assemblies are being used

给你一囗甜甜゛ 提交于 2019-11-28 21:33:17

You can easily see it from the Fuslogvw.exe tool. Start it from the Visual Studio Command Prompt. Configure it with Log Categories = Native Images, Settings + Log all binds to disk. Run your program. Back to fuslogvw, Refresh. It will show you a list of all assemblies that got loaded.

Double-click an entry to see how the assembly got loaded. If it came from the GAC, you'll see:

LOG: IL assembly loaded from C:\Windows\assembly\GAC_MSIL\blahblah

If the Ngen-ed images was used, you'll see:

LOG: Bind to native image succeeded.

You can see if the assembly came from the GAC pretty easily:

Assembly assembly = Assembly.GetExecutingAssembly();

if (assembly.GlobalAssemblyCache)
{
    Console.WriteLine("I'm in the GAC!");
}

EDIT: found a way...

In order to see if it is NGEN'd, you have to read the assembly directly and see if the Precompile Header field has data as per this page. I'm a bit rusty on getting to that value, but that should do it. I don't see a way to figure it out via the reflection methods.

You can use the VMMAP. There, all the .dll (assembly) have location details

In details if your assembly is being loaded from "C:\Windows\assembly\NativeImages(version)..." so your application are using the native image.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!