问题
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);
}
回答1:
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.
来源:https://stackoverflow.com/questions/61260747/dllimport-does-not-work-on-azure-app-service-net-3-1