我最近添加的不是 C# dll我的服务 a 充当 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);
}
最佳答案
这个问题无法解决,因为我们无法直接在Azure上注册这个dll,而且我尝试用代码动态加载也无法成功。建议使用Azure Container
或虚拟机
加载此dll。
关于c# - DLLImport 不适用于 Azure 应用服务网络。 3.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61260747/