我们有自己的C ++编译OCR作为.exe文件,该文件将图像位置作为参数并返回一个字符串,并将其放置在web-API 2应用程序文件夹中的文件夹中,现在我们将OCR作为一个进程启动从网络api获取输出并将其返回。 在本地计算机上一切正常,当我们在服务器中部署API时,除非我们将应用程序池标识替换为应用程序池中的Admin,否则无法检索输出。在此阶段,我们需要使用应用程序池标识(或除admin外的任何其他用户),并且仍然能够从该过程中检索输出,这是我们的代码:
ProcessStartInfo info = new ProcessStartInfo
{
WorkingDirectory = enginepath,
CreateNoWindow = true,
UseShellExecute = false,
FileName = enginepath+"//"+"OCR.exe",
RedirectStandardOutput = true,
Arguments = " "+imageFilepath
};
using (Process process = Process.Start(info))
{
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
return result;
}
}
我们尝试了所有流行的方法,从提供正确的权限,加载用户个人资料= true到现在仍然无法检索输出。 *我们需要能够在Web服务器应用程序中获取输出。