1

我有一些奇怪的行为。

基本上,我的代码在我的本地机器上运行良好,当我使用远程桌面登录服务时,我可以从命令行运行 exe,使用与我在 C# 中给出的完全相同的参数。它完美地工作。

我想知道的是,是否有任何限制或权限阻止 exe 在 Azure WorkerRole 中运行?或者代码中可能有问题阻止它在 WorkerRole 中正常运行,但仅在 Azure 上?

  • 该 exe 不会重定向任何标准输出或标准错误,因此当出现错误时我无法读取任何输出。这也发生在我的本地。
  • 该 exe 设置为复制到 azure 上应用程序的构建目录。该 exe 存在于指定的路径(我已经尝试过 File.Exists 那里以及 pdf 的位置,只是为了确保)
  • 我尝试设置startInfo.CreateNoWindowtrue查看是否可以查看在远程桌面中运行的进程,但我不能。我假设 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 中失败。

4

1 回答 1

0

我会推荐几种不同的方法来解决这个问题。

  1. 普罗克蒙。如果您尝试在某处写入临时文件而被拒绝访问,它将显示您。
  2. 将 WinDBG 附加到 pdf2htmlEX.exe 并查看它是否引发任何异常。

#2 的技巧是将 WinDBG 附加到在 Azure 中运行的进程是很棘手的。请参阅http://blogs.msdn.com/b/kwill/archive/2013/08/26/azuretools-the-diagnostic-utility-used-by-the-windows-azure-developer-support-team.aspx在 Azure VM 上获取 Procmon 和 WinDBG 的快速简便方法,以及将 WinDBG 附加到进程的方法。

于 2013-09-10T20:39:26.713 回答