Azure Worker角色中的意外Process.Start行为

时间:2013-09-10 03:50:15

标签: azure

我有一些奇怪的行为。

基本上,我的代码在我的本地机器上运行正常,当我使用远程桌面登录服务时,我可以从命令行运行exe没有问题,我在C#中使用完全相同的参数。它运作得很好。

我想知道的是,是否有任何限制或权限阻止exe在Azure WorkerRole中运行?或者代码中可能存在错误,导致它无法在WorkerRole中正常运行,但只能在Azure上运行?

  • exe不会重定向任何stdout或stderr,因此在出现错误时我无法读取任何输出。这也发生在我的本地。
  • 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中失败。

1 个答案:

答案 0 :(得分:0)

我建议采用几种不同的方法来解决此问题。

  1. 将procmon。它将告诉您是否因为尝试在某处写临时文件而被拒绝访问。
  2. 将WinDBG附加到pdf2htmlEX.exe,看看它是否抛出任何异常。
  3. #2的诀窍是将WinDBG附加到Azure中运行的进程是棘手的。有关在Azure VM上获取Procmon和WinDBG的快速简便方法,请参阅http://blogs.msdn.com/b/kwill/archive/2013/08/26/azuretools-the-diagnostic-utility-used-by-the-windows-azure-developer-support-team.aspx,以及将WinDBG附加到流程的方法。

相关问题