Calling console application from asp.net

≯℡__Kan透↙ 提交于 2019-12-04 13:44:35

问题


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

回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/20212709/calling-console-application-from-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!