简体   繁体   中英

How do I programmatically find ILASM.EXE in .NET 4.0?

My program needs to call ILASM , but it keeps moving on me. Is there a registry setting or some other value that my program can read so I don't need to hard code the path?

From the SDK Microsoft.Build.Utilities namespace, the ToolLocationHelper class can be used like so:

using Microsoft.Build.Utilities; 

// Use ToolLocationHelper to find ILASM.EXE in the Framework directory
ToolLocationHelper.GetPathToDotNetFrameworkFile("ILAsm.exe", TargetDotNetFrameworkVersion.VersionLatest);

Taken from MSDN sample .

There seem to be a few libraries that are like ILAsm that people have recommended:

  1. http://research.microsoft.com/en-us/downloads/6a34a558-ab57-424f-a799-f0fc458105c1/default.aspx
  2. http://www.microsoft.com/downloads/en/details.aspx?familyid=7e979ed3-416b-43b6-993b-308a160831b6&displaylang=en

You might want to use those (or CodeDom -> C#) instead of calling out to a program.

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft.NETFramework, look for InstallRoot. Add the .net version number to the path in InstallRoot and you've got it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM