Where can I find location of generated file after doing Ngen?
Asked Answered
S

5

25

I did Ngen on a C# executable. It was succesful, but I cannot figure out where the generated file is in my PC. MSDN says it should be in native image cache, still not able to figure out where it is..

EDIT : I want to run objdump on it, hence I need the physical file

EDIT2: my putput of running ngen is :

C:\Documents and Settings\nmea\My Documents\Visual Studio 2008\Projects\Consol
eApplication4\ConsoleApplication4\bin\Release>ngen install ConsoleApplication4.e
xe
Microsoft (R) CLR Native Image Generator - Version 2.0.50727.3053
Copyright (c) Microsoft Corporation.  All rights reserved.
Installing assembly C:\Documents and Settings\nmea\My Documents\Visual Studio
2008\Projects\ConsoleApplication4\ConsoleApplication4\bin\Release\ConsoleApplica
tion4.exe
    Compiling assembly C:\Documents and Settings\nmea\My Documents\Visual Stud
io 2008\Projects\ConsoleApplication4\ConsoleApplication4\bin\Release\ConsoleAppl
ication4.exe (CLR v2.0.50727) ...
ConsoleApplication4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Salicylate answered 14/4, 2011 at 1:23 Comment(0)
D
26

The exact location will vary by version but it will be something similar to this:

C:\Windows\assembly\NativeImages_v2.0.50727_32\System.Web\ace3bede2f516f9e5bca620ad86cc063>System.Web.ni.dll

They start in C:\Windows\assembly and then there is a subfolder NativeImages_vXXX for each .NET version. Then there is a subfolder for each dll that has a native image. Under that another subfolder for a unique version identifier (so you can have multiple native images from different versions of the same dll). Finally the native dll itself.

Note that you cannot navigate to this directory in Windows Exlporer. Use cmd. In Explorer there is a shell extension that hides the details of how the GAC and native images work and just shows you a prettier UI.

Dorthea answered 14/4, 2011 at 1:45 Comment(2)
Turns out you can navigate the GAC in explorer -- have added an answer, not sure if better as a comment.Bewley
Ngen is related to Native Image Cache, not GAC. see: support.microsoft.com/en-us/kb/939242Michail
B
23

Just exploring some similar issues here and you can navigate the GAC in explorer if you make a change in the registry.

Under HKEY_LOCAL_MACHINE\Software\Microsoft\Fusion create a DWORD entry named DisableCacheViewer, and set it to 1.

After that, open a new explorer window and navigate to e.g. c:\windows\assembly.

Bewley answered 14/3, 2012 at 15:56 Comment(0)
A
2

You'll find them in the NativeImages_blabla folder in c:\windows\assembly. Also I've noted that .NET 3.5 and above actually does not allow physically accessing the NGENed image. I guess it reverted to using one large database for all files but I cant be sure since the generated images are no where to be seen on the disk.

Airsickness answered 14/4, 2011 at 1:28 Comment(4)
there is only one folder called "download" under c:\windows\assembly in my PC. could not find any file beginnig with "Native" there..Salicylate
running from visual c# 2008 sdk prompt. Ngen version is "Microsoft (R) CLR Native Image Generator - Version 2.0.50727.3053"Salicylate
Then be sure that file exists in the native image cache, use ngen /show MyAssembly and then search for the assembly inside the whole Windows directory. I'm sure it will come up if properly installed in the cache.Airsickness
yes, it is there when i tried show : "Native Images:ConsoleApplication4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"Salicylate
A
2

Try ngen display AssemblyName /verbose | findstr "File:"

ex: %windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe display System.Xaml /verbose | findstr "File:"

Amaze answered 19/7, 2013 at 7:17 Comment(0)
S
1

Well, you see it took a long long time to find where the location is!

Well, it is inside c:\Windows\assembly folder, but when I opened this folder then I was only be able to see the .NET assemblies, so I thought there will be some hidden folders. So I open the command prompt with administrative privileges then I was able to see list of folders as shown below...

GAC,  GAC_32,  GAC_64,  GAC_MSIL,  NativeImages_v2.0.50727_32
NativeImages_v2.0.50727_64,  NativeImages_v4.0.30319_32,
NativeImages_v4.0.30319_64

You see it's amazing. I mean, here I can only see the required folders, but not the assemblies. Well, no problem, be happy.

So my application was built in v4 and 64-bit compilation so therefore my required EXE file was in the root of the NativeImages_v4.0.30319_64 folder.

Shows answered 23/4, 2017 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.