2
votes

I tried to add an executable to my Azure worker role and call it from the code. But I'm not 100% sure how the path has to look like. I added the executable in Visual Studio to my worker role project, set to content and copy always. In my worker role, I call

Process.Start(Path.Combine(Environment.GetEnvironmentVariable("RoleRoot"), "Executable.exe"));

Which results in

AppDomain Unhandled Exception Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) [...] at System.Threading.ThreadHelper.ThreadStart()

The name of my azure project is "AzureProject", the name of my worker role is "QueueWorker", the executable "Executable.exe". I suppose the path is wrong.

1

1 Answers

5
votes

There's something wrong with the path, you are correct. Here are couple of things you might want to check:

  • "Copy to output" property of the executable file, which is part of your project, must be set to "copy alywas"
  • Try adding @"\approot" after the RoleRoot and before "Executable.exe" in your path.combine.
  • You may also try getting the Executable location from Assembly.GetExecutingAssembly().Location - this shall give you the path to the assembly of your worker role, where your executable should also reside. Just not use that approach with WebRole, it has different meaning there (temporary asp.net files).