Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
988 views
in Technique[技术] by (71.8m points)

c# - DLLImport does not work on Azure App Service Net. 3.1

I recently added not C# dll to my service a which acts as HTTP Client. On my Local Machine (Windows 10) everything works perfectly. When tried to send a request on Azure i get following response.

  <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> 

The developer of the dll and I debugged (VS Remote Debug) the App Service and the this exception occurs, when we first tried to use DllImport. He claims there is no network request send at this point of time. But either way he tried to fix a proxies bug in dll, but it still does not work on Azure. The dll depends on the kernel.dll and msvcrt.dll should not be a problem?

In App Insight I get this exception at the same time, i send the request, but i am not sure if the exceptions are related: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details. Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

SystemInfo: OS version: Microsoft Windows NT 10.0.14393.0 64 bit system: True 64 bit process: False Processor count: 4

The dll is on the server with right Version.

Here the exception occurs:

    [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);
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This problem can't be solved, because we can't register this dll directly on Azure, and I can't succeed in trying dynamic loading with code. It is recommended to use Azure Container or virtual machine to load this dll.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...