NGen will be in the .NET framework directory, for example:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
Option 1 - GetCORSystemDirectory () is a sytem API call that you can use to get the .NET Framework directory, but the problem is that it is like reading the documentation you need to call from a. NET Thus, you can run a small .NET application and write the result of GetCORSystemDirectory () to an ini file. Perhaps find this feature and see if you can find anything useful through Google.
Option 2 - you can guess the .NET platform in the expected path and iterate through the directories and find the one that starts with "v2.0."
Option 3 - Just extract ngen from your isntaller and then run it. This is what I did with regasm on occasion. I am not sure what side effects you may encounter, whether it is completely legal, or if there are other files that it depends on. If this is something like regasm.exe, you should be fine while the .NET platform is already installed.
source share