【发布时间】:2019-02-22 08:38:40
【问题描述】:
我想通过 Azure Functions 执行依赖于 DLL 的 C++ .exe。它适用于我的本地机器以及使用 kudo 控制台启动 exe 时。
就像Run .exe executable file in Azure Function 中的帖子一样,我建议我准备好 run.csx 并将 .exe 和 DLL 加载到同一文件夹“D:\home\site\wwwroot\QueueTriggerCSharp1\”中。
当不需要 C++ 代码中的 DLL 时,它可以工作。否则,C++ 找不到 DLL(与 .exe 位于同一文件夹中),退出代码为 -1073741701。 如果我不上传 DLL,我会得到相同的退出代码。
我应该在哪里加载 DLL,或者还有其他原因吗?
run.csx-代码:
using System;
using System.Threading;
using System.Diagnostics;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
string WorkingDirectoryInfo =@"D:\home\site\wwwroot\QueueTriggerCSharp1\";
string ExeLocation = @"D:\home\site\wwwroot\QueueTriggerCSharp1\WriteDatebase2.exe";
Process proc = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = WorkingDirectoryInfo;
log.Info($"WorkingDirectory: {info.WorkingDirectory}");
info.FileName = ExeLocation;
info.Arguments = "";
info.UseShellExecute = false;
info.CreateNoWindow = true;
proc.StartInfo = info;
proc.Start();
proc.WaitForExit();
int exitcode=proc.ExitCode;
log.Info($"ExitCode: {exitcode}");
}
当我使用 python azure 函数启动 exe 时,也会出现同样的错误。在 kudo 控制台中启动 python 脚本有效。
有人有类似的问题吗?
谁能帮帮我? 谢谢!
【问题讨论】:
-
感谢您的回复!有用!它在 Kudo 控制台中有效而在 azure 函数中无效的原因可能是什么?
-
我用与 azure 函数相同的方法(使用 DLL 调用 C++ exe)编写了一个控制台应用程序,并将生成的 exe 放在不同的位置。如果我用 Kudo 控制台执行控制台应用程序,它就可以工作。如果我使用 azure 函数执行控制台应用程序,控制台应用程序可以工作,但 C++ exe 会失败,并显示与以前相同的退出代码。
-
抱歉,我无法解释。可能需要看现场重现。
-
太糟糕了,还是谢谢。如果您有其他想法,可以联系我们。
-
您找到解决方案了吗?我也有同样的问题。
标签: c++ azure dll exe azure-functions