简体   繁体   English

如何在.NET 4.0中以编程方式查找ILASM.EXE?

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

My program needs to call ILASM , but it keeps moving on me. 我的程序需要调用ILASM ,但它继续向我发展。 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: 从SDK Microsoft.Build.Utilities命名空间,可以像这样使用ToolLocationHelper类

using Microsoft.Build.Utilities; 

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

Taken from MSDN sample . 取自MSDN样本

There seem to be a few libraries that are like ILAsm that people have recommended: 似乎有一些库像人们推荐的ILAsm:

  1. http://research.microsoft.com/en-us/downloads/6a34a558-ab57-424f-a799-f0fc458105c1/default.aspx 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 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. 您可能希望使用这些(或CodeDom - > C#)而不是调用程序。

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft.NETFramework, look for InstallRoot. HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft.NETFramework,查找InstallRoot。 Add the .net version number to the path in InstallRoot and you've got it. 将.net版本号添加到InstallRoot中的路径,您就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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