DLLImport 在 Azure 应用服务网络上不起作用。 3.1
Posted
技术标签:
【中文标题】DLLImport 在 Azure 应用服务网络上不起作用。 3.1【英文标题】:DLLImport does not work on Azure App Service Net. 3.1 【发布时间】:2020-04-16 22:00:15 【问题描述】:我最近向我的服务 a 添加了 not C# dll,它充当 HTTP Client。在我的本地机器(Windows 10)上一切正常。当尝试在 Azure 上发送请求时,我得到以下响应。
<h3>There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.</h3>
当我们第一次尝试使用 DllImport 时,我和 dll 的开发人员调试(VS 远程调试)应用服务并出现此异常。他声称此时没有发送网络请求。 但无论哪种方式,他都试图修复 dll 中的代理错误,但它仍然无法在 Azure 上运行。这个dll依赖于kernel.dll和msvcrt.dll应该不会有问题吧?
在 App Insight 中,我同时收到此异常,我发送请求,但我不确定异常是否相关: 启动程序集 Microsoft.AspNetCore.AzureAppServices.HostingStartup 无法执行。有关更多详细信息,请参阅内部异常。无法加载文件或程序集“Microsoft.AspNetCore.AzureAppServices.HostingStartup,Culture=neutral,PublicKeyToken=null”。该系统找不到指定的文件。
系统信息: 操作系统版本:Microsoft Windows NT 10.0.14393.0 64位系统:真 64位进程:假 处理器数量:4
该 dll 位于具有正确版本的服务器上。
这里出现异常:
[DllImport(LIB_32, EntryPoint = SYMBOL_FREE)]
internal static extern void Free32(IntPtr response);
[DllImport(LIB_64, EntryPoint = SYMBOL_FREE)]
internal static extern void Free64(IntPtr response);
[DllImport(LIB_32, EntryPoint = SYMBOL_INVOKE)]
internal static extern IntPtr Invoke32([In] byte[] request);
[DllImport(LIB_64, EntryPoint = SYMBOL_INVOKE)]
internal static extern IntPtr Invoke64([In] byte[] request);
protected override IntPtr PerformInvokeForArchitecure(byte[] request)
if (Is64BitSystem)
return Invoke64(request);
return Invoke32(request);
【问题讨论】:
【参考方案1】:这个问题解决不了,因为我们不能直接在Azure上注册这个dll,用代码尝试动态加载也无法成功。推荐使用Azure Container
或virtual machine
来加载这个dll。
【讨论】:
谢谢,我是对的,嵌入式程序集可以工作吗? 我不确定,我不知道嵌入式组装,你可以试试。以上是关于DLLImport 在 Azure 应用服务网络上不起作用。 3.1的主要内容,如果未能解决你的问题,请参考以下文章
有些东西阻止了Azure上Ubuntu localhost的流量