Stack Overflow Asked by Sanket Wankhede on December 18, 2020
protected void Button1_Click(object sender, EventArgs e)
{
try
{
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = Server.MapPath(@"~\bin\HelloApp.exe");
process1.StartInfo.Arguments = "";
process1.Start();
process1.WaitForExit();
process1.Close();
}
catch (Exception ex)
{
Response.Write(ex);
}
}
It is impossible to call another UI application by the application hosted in IIS. Due to the fact that there is no user session to render the UI. Since Windows Vista, there is a mechanic called Session Isolation, which separates the application and the service.
However, it will work when we start the application by Visual Studio locally since the current session is inherited with the account running Visual Studio.
For details, please refer to the below links.
How to start a process from an IIS hosted WCF service?
IIS Session isolation problem
Answered by Abraham Qian on December 18, 2020
try this code and see if you get any error. if you get an error check whether the published code bin has the HelloApp.exe.
protected void Button1_Click(object sender, EventArgs e)
{
string fileNameWithPath = Path.GetFullPath(@"~\bin\HelloApp.exe");
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "";
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = true;
startInfo.FileName = fileNameWithPath;
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
StreamReader outputReader = exeProcess.StandardOutput;
StreamReader errorReader = exeProcess.StandardError;
string errors = errorReader.ReadToEnd();
if (!string.IsNullOrEmpty(errors))
throw new Exception(errors);
}
}
Answered by Gan3i on December 18, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP