【发布时间】:2015-10-10 19:41:52
【问题描述】:
我正在用 C# 从 Web 服务执行简单的 C++ (.exe)。它在开发环境(在 Visual Studio 中)中运行良好,但是当我托管在 IIS 中时,它不会被执行。我尝试使用简单的 C# 控制台应用程序,它对我来说很好。 我已经授予权限
- 大家
- IUSR
- 本地服务
- 网络服务
- 网络
- IIS_Users
从 IIS 到编辑权限。
[WebMethod]
public string GETOCR()
{
string OCROutput ="";
ProcessStartInfo startinfo = new ProcessStartInfo("C:\\BSG\\ProcessOCR.exe", "12,13;964,15;964,634;9,634 \"C:\\BSG\\20150709_224156.jpg\" ");
startinfo.CreateNoWindow = true;
startinfo.UseShellExecute = false;
startinfo.RedirectStandardOutput = true;
startinfo.WindowStyle = ProcessWindowStyle.Normal;
try
{
using (Process exeProcess = Process.Start(startinfo))
{
OCROutput = exeProcess.StandardOutput.ReadToEnd();
//Response.Write(OCROutput);
exeProcess.WaitForExit();
}
}
catch (Exception)
{
throw;
}
return OCROutput;
}
【问题讨论】:
-
您期望看到它执行吗?情况并非如此,它将在 IIS 正在使用的用户帐户下运行,因此将与您和您的桌面隔离。如果进程启动失败会引发异常,是这样吗? exe是否出现在所有用户任务列表中?
-
你怎么知道它没有被执行?您在展示的 C# 代码中是否遇到了一些异常?什么例外?
标签: c# asp.net web-services iis