title: ngen and profiling
body: <p>I'm trying to use NGen to see if native images of my application run better than the .NET ones. However, I'm having a little bit of trouble figuring out what to do.</p>
  
  <p>My application is called <em>MyApp.exe</em> and it has several dependency DLLs.</p>
  
  <p>I opened up the VS 2010 Command Prompt and ran:</p>
  
  <pre><code>ngen install MyApp.exe /Profile
  </code></pre>
  
  <p>The command output did not suggest any issues had been encountered.</p>
  
  <p>I then went to C:\Windows\assembly to try and run the EXE but I couldn't find it there (I'm on Windows 7). A little bit of digging told me to use the command prompt to browse into C:\Windows\assembly\NativeImages_v4.0.30319_32. I was eventually ably to locate my MyApp.ni.exe there but of course couldn't open the containing folder in explorer.</p>
  
  <p>I tried to run the program and it told me:</p>
  
  <p>"C:\Windows\assembly\NativeImages_v4.0.30319_32...\MyApp.ni.exe is not a valid Win32 application."</p>
  
  <p>The command output said <em>Access is denied.</em></p>
  
  <p>I had two questions:</p>
  
  <ol>
  <li>How can I run this program so that I can execute the native version.</li>
  <li>How would I go about profiling it? Looks like I won't be able to locate that folder from within the VS2010 profiler because it cannot be seen in explorer.</li>
  </ol>
  
  <p>Thanks.</p>