gpt4 book ai didi

.net - 在 Azure 辅助角色中启动可执行文件 : path problems

转载 作者:行者123 更新时间:2023-12-02 06:16:27 25 4
gpt4 key购买 nike

我尝试将可执行文件添加到我的 Azure 辅助角色并从代码中调用它。但我并不能 100% 确定路径是什么样子。我将 Visual Studio 中的可执行文件添加到我的辅助角色项目中,设置为内容并始终复制。在我的 worker 角色中,我调用

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

结果

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”。我想路径是错误的。

最佳答案

路径有问题,你是对的。以下是您可能需要检查的几件事:

  • 作为项目一部分的可执行文件的“复制到输出”属性必须设置为“复制 alywas
  • 尝试在 Path.combine 中的 RoleRoot 之后、“Executable.exe”之前添加 @"\approot"。
  • 您还可以尝试从 Assembly.GetExecutingAssembly().Location 获取可执行文件位置 - 这将为您提供辅助角色程序集的路径,您的可执行文件也应驻留在其中。只是不要在 WebRole 中使用这种方法,它在那里有不同的含义(临时 asp.net 文件)。

关于.net - 在 Azure 辅助角色中启动可执行文件 : path problems,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8255852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com