Calling console application from asp.net

2019-03-21 11:20发布

I try to call console appliction from asp.net when i put breakpoint in console app why it can't stop there.How can i call console application?

 var proc = Process.Start("D:\\Edefter\\EFaturaConsoleTxtParser\\bin\\Debug\\EFaturaConsoleTxtParser.exe", "/arg1 /arg2");
                proc.WaitForExit();

2条回答
We Are One
2楼-- · 2019-03-21 11:53

While starting a process programmatically, the 'UserShellExcute' property must be 'false'. Otherwise, the CreateNoWindow property value gets ignored and new window is created.

Example:

 ProcessStartInfo startinfo = new ProcessStartInfo();
 startinfo.FileName = @"demoApplication.exe";
 startinfo.Arguments = "arg1 arg2";
 startinfo.CreateNoWindow = true;
 startinfo.UseShellExecute = false;
 Process myProcess = Process.Start(startinfo);

Source: http://msdn.microsoft.com

查看更多
叛逆
3楼-- · 2019-03-21 11:55

I'm not sure about this but anyway you can try

  ProcessStartInfo startinfo = new ProcessStartInfo();   
    startinfo.FileName =@"D:\\Edefter\\EFaturaConsoleTxtParser\\bin\\Debug\\EFaturaConsoleTxtParser.exe";   
    startinfo.CreateNoWindow = true;   
    startinfo.UseShellExecute = true; 
    Process myProcess = Process.Start(startinfo);
    myProcess.Start();
查看更多
登录 后发表回答