【问题标题】:Execute command program执行命令程序
【发布时间】:2014-04-24 02:58:33
【问题描述】:

在 C# 中执行控制台命令程序时出现以下错误

'CutyCaptApp.vshost.exe' (Managed (v4.0.30319)): Loaded  C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'CutyCaptApp.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'vshost.NotifyLoad' (0x19a4) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x6ac) has exited with code 0 (0x0).
'CutyCaptApp.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Srinivasa\VisualStudioProject\CutyCaptApp\CutyCaptApp\bin\Debug\CutyCaptApp.exe', Symbols loaded.
The thread '<No Name>' (0x1d3c) has exited with code 0 (0x0).

这是我的 C# 代码:

static void Main(string[] args)
{
   Process process = new System.Diagnostics.Process();
   ProcessStartInfo startInfo = new ProcessStartInfo();
   startInfo.FileName = "C:\\Srinivasa\\VisualStudioProject\\CutyCapt_Pdf_Code\\release\\CutyCapt.exe";
   //startInfo.Arguments = f;
   Process.Start(startInfo);
   //startInfo.FileName =    "C:\\Srinivasa\\VisualStudioProject\\CutyCapt_Pdf_Code\\release\\CutyCapt.exe";    startInfo.Arguments = "--url=C:/Users/UPPALASX/Desktop/New folder/ResearchMap.html --out=C:\\Srinivasa\\VisualStudioProject\\CutyCapt_Pdf_Code\\release\\Out_Embeded_RM.png";
   process.StartInfo = startInfo;
   process.Start();
   process.WaitForExit();
}

错误来自哪里?

【问题讨论】:

  • 您使用的是哪个操作系统?如果 Windows 7 则尝试以管理员身份运行 VS 并检查。
  • 这不是错误。
  • 我无法以管理员模式打开VS。
  • 这不是错误。这是 Visual Studio 中的输出窗口。
  • 你为什么认为首先是一个错误?你预期会发生什么,你观察到了什么?您是否尝试调试该程序?您不必以管理员身份运行 Visual Studio 即可调试程序。

标签: c# .net command-line console-application


【解决方案1】:

您的一个参数的文件夹路径中有一个空格,因此它将被解释为两个参数。参数由空格分隔,因此如果参数包含空格,则必须用双引号括起来。

【讨论】:

  • 我已尝试使用参数 file:///C:/Users/UPPALASX/Desktop/New%20folder/ResearchMap.html 但得到相同的错误
  • 我是不是想象自己说要用双引号将路径括起来?
【解决方案2】:

我在您的输出中看不到任何错误。应用程序的行为可能与您预期的不同,但它没有抛出明显的错误。

您是否尝试过使用命令行参数运行 CutyCapt.exe 程序,而不是从您的应用程序中检查它是否使用这些参数运行正常?

【讨论】:

  • 是的,我使用 CMD 运行了 CutyCapt.exe,它运行成功。我的命令是:">CutyCapt.exe --url=file:///C:/Users/UPPALASX/Desktop/New %20folder/ResearchMap.html --out=Out_Embeded_RM.pdf --page-width=800 --page-height=6500"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-06
  • 2019-06-20
  • 1970-01-01
相关资源
最近更新 更多