开发者

Calling exe inside of an Azure worker role

I am trying to call an executable inside of a worker role

I tried different executables:

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)

My aim is to be able to run program1.exe.

Results:

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.
开发者_开发技巧

So, I wanted to understand why program1.exe is not working but couldn't find the reason. I understood that the problem is not specific to program1.exe. For any win32 application, it is problematic.

What can be the reason of this?

Here is the part of the code which deals with calling an external application:

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();

program2.exe works so, I do not have any problem with uploading the file to a blob. I couldn't find the problem. Can it be related with passing commandline arguments? Do I need to specify additional things for a C coded executable?

By the way, all of the tests are successful in the emulator(i.e. the development environment)


My gut reaction is that you should check that all the necessary dll's for that win32 exe are available - especially dll's like the Visual C++ redistributables - if any of those is missing and required then the application won't successfully launch. Use dumplib or depends to see what is needed.

Another thing that might cause problems would be if your exe doesn't have necessary read/write access to one of the paths you are passing in.

Other mechanisms that might help you debug this:

  • check the Windows event logs (using azure diagnostics) to see if anything any events are being recorded
  • in your c# code, check the exit code of your Process - plus also try intercepting the StandardError
  • in your C code, add additional logging to see if the test executables are somehow "crashing" somewhere along the way
  • as @Jason Haley suggests in his comment, try remote desktop'ing into your VM to see what is occurring.

One final note - for optimal use of Azure, you should probably target 64-bit C compilation as the Azure VMs are all 64-bit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜