执行命令程序

时间:2014-03-18 12:19:34

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

在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();
}

错误来自哪里?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

我看不到输出中的任何错误。应用程序可能没有按预期运行,但它没有引发明显的错误。

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