【问题标题】:Unable to run ILAsm using ProcessInfo无法使用 ProcessInfo 运行 ILAsm
【发布时间】:2012-10-13 08:38:45
【问题描述】:

我正在尝试使用 bat 文件和 C# 编译 IL 代码。这是一段C#代码

ProcessStartInfo processStartInfo = new ProcessStartInfo(ILCompiler, @"c:\Windows\Microsoft.NET\Framework\v4.0.30319\" + ILCompiler + 
    " "+OutILFile+" /exe /output:" + OutExeFile + " /debug=IMPL");
processStartInfo.UseShellExecute = false;
processStartInfo.CreateNoWindow = false;
using (Process.Start(processStartInfo)) ;

这是一个bat文件

c:\Windows\Microsoft.NET\Framework\v4.0.30319\ilasm.exe Source.il /exe /output:my-assebmly.exe /debug=IMPL
pause

运行 ILAsm 的字符串完全相同(即processStartInfo.Arguments = Arguments = "c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\ilasm.exe Source.il /exe /output:my-assebmly.exe /debug=IMPL")

尽管如此,当我使用 C# 运行时出现错误

程序无法启动,因为您的计算机缺少 fusion.dll。尝试重新安装程序以解决此问题。

我该如何解决?我需要使用 C# 运行 ILAsm。

【问题讨论】:

  • 不,我是说 ILAsm。我需要将 *.il 文件编译为 *.exe。
  • 这仅仅是工作路径没有设置吗?尝试将工作路径设置为 ilasm 所在的文件夹
  • 尝试设置processStartInfo.WorkingDirectory = @"c:\Windows\Microsoft.NET\Framework\v4.0.30319\"
  • @Nacereddine,现在看来它正在工作。太棒了。
  • 我会将其作为答案发布,以便您关闭此问题。

标签: c# .net cil il ilasm


【解决方案1】:

试试这个:

processStartInfo.WorkingDirectory = @"c:\Windows\Microsoft.NET\Framework\v4.0.30319\"

【讨论】:

  • 但是,现在说找不到*.il 来编译。这是因为工作目录。
  • 是的。使用 .il 的完整路径。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-26
  • 2018-01-12
  • 2019-02-01
  • 1970-01-01
  • 2015-03-30
相关资源
最近更新 更多