我正在从azure API应用程序内调用托管x64 dll。我通过浏览来引用它。它依赖于opencv dll和数据文件夹中的某些文件,所有文件都在根级别具有构建操作作为内容,并复制到输出目录作为始终复制。我正在使用64位版本的IIS Express。
我创建了一个测试项目,并引用了Azure API应用程序以测试方法中的功能,并且无论测试项目还是Azure API应用程序目标x64平台,它都可以正常工作。
当我尝试自行运行azure API应用程序时出现问题,它失败并显示为“无法加载文件或程序集'some.dll'或其依赖项之一。找不到指定的模块。” >
赞赏有关如何弄清楚问题可能出在哪里的任何想法。
答案 0 :(得分:0)
要使其在本地调试Azure api时可以正常工作,我必须将当前工作目录设置为bin文件夹,托管dll和opencv依赖项驻留在该文件夹中。
为此,我将此行添加到Global.asax.cs中的Application_Start方法中
Environment.CurrentDirectory = HttpRuntime.BinDirectory;
但是此解决方案在将其部署到Azure时不起作用,因此我不得不在xdt
文件夹中放置一个D:\home\site
文件,以将bin路径添加到系统PATH变量。
applicationHost.xdt
文件的外观如下。
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<runtime xdt:Transform="InsertIfMissing">
<environmentVariables xdt:Transform="InsertIfMissing">
<add name="PATH" value="%PATH%;%HOME%\site\wwwroot\bin" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
</environmentVariables>
</runtime>
</system.webServer>
</configuration>