C#进程异常
本文关键字:异常 进程 | 更新日期: 2023-09-27 18:00:20
运行此代码时,我得到一个异常
String cmd = "-redir:sim applu.res -max:inst {0} -pred {1} -assoc {2} -lvpt {3} -speedup {4} applu.ss<applu.in";
for (int i = 0; i < parameters.Length; i++) {
cmd = cmd.Replace ("{" + i + "}", parameters [i]);
}
Console.WriteLine (cmd);
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "./sim-spred";
process.StartInfo.Arguments = cmd;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
Console.WriteLine(process.StandardOutput.ReadToEnd());
源位于调试文件夹
由于您没有告诉我们异常在哪里,我不知道这是否与您的问题有关。但是,
这就是String.Format
存在的原因!
String cmd = "-redir:sim applu.res -max:inst {0} -pred {1} -assoc {2} -lvpt {3} -speedup {4} applu.ss<applu.in";
for (int i = 0; i < parameters.Length; i++) {
cmd = cmd.Replace ("{" + i + "}", parameters [i]);
}
试试这个:
var cmd = String.Format("-redir:sim applu.res -max:inst {0} -pred {1} -assoc {2} -lvpt {3} -speedup {4} applu.ss<applu.in",
max_inst, pred, assoc, lvpt, speedup);