我有一些奇怪的行为。
基本上,我的代码在我的本地机器上运行良好,当我使用远程桌面登录服务时,我可以从命令行运行 exe,使用与我在 C# 中给出的完全相同的参数。它完美地工作。
我想知道的是,是否有任何限制或权限阻止 exe 在 Azure WorkerRole 中运行?或者代码中可能有问题阻止它在 WorkerRole 中正常运行,但仅在 Azure 上?
- 该 exe 不会重定向任何标准输出或标准错误,因此当出现错误时我无法读取任何输出。这也发生在我的本地。
- 该 exe 设置为复制到 azure 上应用程序的构建目录。该 exe 存在于指定的路径(我已经尝试过 File.Exists 那里以及 pdf 的位置,只是为了确保)
- 我尝试设置
startInfo.CreateNoWindow
以true
查看是否可以查看在远程桌面中运行的进程,但我不能。我假设 WorkerRole 和远程桌面是机器上的不同用户。
这是我的代码:
LocalResource tempStorage = RoleEnvironment.GetLocalResource("TempStorage");
string tempDir = tempStorage.RootPath;
string tempName = Guid.NewGuid().ToString();
string tempFile = Path.Combine(tempDir, tempName + ".pdf");
string saveFile = tempName + ".html";
string exeDir = Path.Combine(Environment.GetEnvironmentVariable("RoleRoot") + @"\", @"approot\Resources\");
File.WriteAllBytes(tempFile, fileBytes);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = Path.Combine(exeDir, "pdf2htmlEX.exe");
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = exeDir;
//startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = String.Format("--zoom 1.5 --dest-dir \"{0}\" \"{1}\" \"{2}\"", tempDir, tempFile, saveFile);
startInfo.CreateNoWindow = true;
using (Process proc = Process.Start(startInfo))
{
proc.WaitForExit(30000);
}
// saveFile does not exist here or any time after the process exists
使用这个项目的 exe。太好了:https ://github.com/coolwanglu/pdf2htmlEX
编辑:找到一些日志信息...
Faulting application name: pdf2htmlEX.exe, version: 0.0.0.0, time stamp: 0x520bb881
Faulting module name: pdf2htmlEX.exe, version: 0.0.0.0, time stamp: 0x520bb881
Exception code: 0xc0000005
Fault offset: 0x0013a6e4
Faulting process id: 0x9cc
Faulting application start time: 0x01ceaf4109e78f34
Faulting application path: C:\Resources\directory\96bf7ddee08d45a8883fe2a603131842.WorkerRole.TempStorage\pdf2htmlEX.exe
Faulting module path: C:\Resources\directory\96bf7ddee08d45a8883fe2a603131842.WorkerRole.TempStorage\pdf2htmlEX.exe
Report Id: 48260a60-1b34-11e3-93ef-00155d4334a7
Faulting package full name:
Faulting package-relative application ID:
该过程在预处理所有页面后停止,然后在工作时失败。如果我运行“DebugView”,我会得到:
[1356] Invalid parameter passed to C runtime function.
[1356] Error -
[1356] RtlWerpReportException failed with status code :-1073283067. Will try to launch the process directly
[1356]
也许这是应用程序的错误?(也许不应该写入内存)我仍然不明白为什么这只在 WorkerRole 中失败。