如何修复"Unable to load shared library 'httpapi.dll' or one of its dependencies"



我是 Linux 的新手。但是我需要在此操作系统上运行asp网络核心应用程序。我在 Windows 10 中成功构建和编译应用程序,但是当我将其移动到 linux 并尝试运行时,会出现以下异常

Application startup exception: System.TypeInitializationException: The type initializer for 'Microsoft.AspNetCore.Server.HttpSys.HttpApi' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'httpapi.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libhttpapi.dll: cannot open shared object file: No such file or directory
   at Microsoft.AspNetCore.Server.HttpSys.HttpApi.HttpInitialize(HTTPAPI_VERSION version, UInt32 flags, Void* pReserved)   at Microsoft.AspNetCore.Server.HttpSys.HttpApi.InitHttpApi(UInt16 majorVersion, UInt16 minorVersion)
   at Microsoft.AspNetCore.Server.HttpSys.HttpApi..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.HttpSys.HttpSysListener..ctor(HttpSysOptions options, ILoggerFactory loggerFactory)
   at Microsoft.AspNetCore.Server.HttpSys.MessagePump..ctor(IOptions`1 options, ILoggerFactory loggerFactory, IAuthenticationSchemeProvider authentication)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

我真的需要使用httpSys驱动程序。那是在我的代码中

 public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseHttpSys();

你不能在Linux上运行Http.sys,它是一个仅限Windows的托管选项。请参阅文档。

Http.sys与Windows(和IIS,它是Web服务器Microsoft)紧密耦合。

对于Linux,你必须使用Kestrel。

相关内容

最新更新