启动一个可执行文件中的Azure工作者角色:路径问题 [英] Starting an executable file in an Azure worker role: path problems

查看:156
本文介绍了启动一个可执行文件中的Azure工作者角色:路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试的可执行文件添加到我的Azure工作者角色,并从code调用它。但我不是100%确定如何,这条道路的样​​子。 我加在Visual Studio中的可执行文件到我的辅助角色的项目,设置为内容和复制始终。 在我的辅助角色,我称之为

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

这导致

AppDomain中未处理的异常异常:系统无法找到   文件中指定的   System.Diagnostics.Process.StartWithShellExecuteEx(的ProcessStartInfo   StartInfo的)[...]在System.Threading.ThreadHelper.ThreadStart()

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

我的Azure项目的名称是AzureProject,我的工人角色的名称是QueueWorker,可执行Executable.exe。我想的路径是错误的。

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.

推荐答案

有一些错误的路径,你是正确的。这里有几件事情,你可能要检查:

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

  • 复制到输出的可执行文件,这是项目的一部分财产,必须设置为复制alywas
  • 的RoleRoot后,并在您path.combineExecutable.exe之前尝试添加@\为approot。
  • 您也可以尝试从Assembly.GetExecutingAssembly获取可执行文件的位置()位置 - 这将给你的路径,你的工人角色组件,在您的可执行文件也应该驻留。只要不使用带有WebRole这种方法,它有不同的意义有(临时asp.net文件)。
  • "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).

这篇关于启动一个可执行文件中的Azure工作者角色:路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆