c# - DLLImport 不适用于 Azure 应用服务网络。 3.1

标签 c# azure asp.net-core .net-core dllimport

我最近添加的不是 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/

相关文章:

c# - 基于 CLR 的语言中的基于一的索引?

Azure 登录工作时出错 - 获取租户消息时出错 - 代理设置?

jquery - 超过多部分主体长度限制 16384

angular - 如何修改 csproj PublishRunWebpack 以包含来自外部目录的静态文件

c# - 是否可以使用 Dapper 执行一个链接到 2 个数据库上的表的查询?

c# - 3 维波的法线

c# - 如何检查商品在特定日期范围内是否可用

c# - NavigationService 提示从未附加到任何 View 的类执行 "FileNotFound"

azure - 如何通过 Azure DocumentDB 以事务方式使用 Azure 服务总线

api - Microsoft 的 Face API 是否需要 Azure?