我试图在worker角色中调用可执行文件
我试过不同的可执行文件:
1-program1.exe (C code compiled with visual studio, target: Win32)
2-program2.exe (C# code, target: x86, this is a dummy program it only creates a text file)
3-program3.exe (C code compiled with visual studio, target: win32, this is a dummy program it only creates a text file)
Run Code Online (Sandbox Code Playgroud)
我的目标是能够运行program1.exe.
结果:
1- no signs of success. It should generate some files for any successful run. No files were generated.
2- success. It creates the text file.
3- no signs of success. No file was generated.
Run Code Online (Sandbox Code Playgroud)
所以,我想了解为什么program1.exe无法正常工作但无法找到原因.我明白问题不是program1.exe特有的.对于任何win32应用程序,它都是有问题的.
这可能是什么原因?
以下是处理调用外部应用程序的代码部分:
var localStorage = RoleEnvironment.GetLocalResource("WorkerLocalStorage");
String workingDir = localStorage.RootPath + @"job";
var appRoot = Path.Combine(Environment.GetEnvironmentVariable("RoleRoot")
+ @"\", @"approot");
String workingDir = localStorage.RootPath + @"job";
String cmdline = "command1 command2";
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.CreateNoWindow = false;
startinfo.UseShellExecute = true;
startinfo.FileName = Path.Combine(appRoot, @"program1.exe");
//startinfo.FileName = Path.Combine(appRoot, @"program2.exe");
//startinfo.FileName = Path.Combine(appRoot, @"program3.exe");
startinfo.Arguments = cmdline;
startinfo.WorkingDirectory = workingDir;
Process exeProcess = Process.Start(startinfo);
exeProcess.WaitForExit();
Run Code Online (Sandbox Code Playgroud)
program2.exe工作原理,我将文件上传到blob没有任何问题.我找不到问题.它可以与传递命令行参数相关吗?我是否需要为C编码的可执行文件指定其他内容?
顺便说一句,所有测试都在模拟器中成功(即开发环境)
我的直觉反应是,你应该检查所有必需的dll的对于Win32的EXE可供选择 - 尤其是DLL的喜欢的Visual C++可再发行 - 如果有的话那些缺少和需要,然后应用程序将无法成功启动.使用dumplib或依赖于查看所需内容.
另一个可能导致问题的方法是,如果你的exe没有对你传入的其中一个路径进行必要的读/写访问.
其他可能帮助您调试此问题的机制:
最后一点 - 为了最佳地使用Azure,您可能应该以64位C编译为目标,因为Azure VM都是64位.
| 归档时间: |
|
| 查看次数: |
3347 次 |
| 最近记录: |