簡體   English   中英

.NET 內核 HTTP 錯誤 500.0 - ANCM 進程內處理程序加載失敗

[英].NET Core HTTP Error 500.0 - ANCM In-Process Handler Load Failure

嘗試在瀏覽器中運行 .NET Core web api 應用程序,但不斷收到以下錯誤:

HTTP 錯誤 500.0 - ANCM 進程內處理程序加載失敗

我正在使用 .NET 框架 5

VS 2019 社區版 16.11.8

已安裝以下 .NET 核心組件:

  • ASP.NET 核心運行時 5.0.13
  • ASP.NET 核心托管包
  • .NET 桌面運行時 5.0.13

AspNetCoreModuleV2 安裝並存在於:

程序.cs

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

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

啟動.cs

public class Startup
{
    private const string _dev = "Development";

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers(options => options.EnableEndpointRouting = false);
        services.AddSwaggerGen();
        services.AddRepositories(Configuration);
        services.AddServices(Configuration);
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.EnvironmentName == _dev)
        {
            app.UseDeveloperExceptionPage();
            app.UseSwagger();
            app.UseSwaggerUI();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
                options.RoutePrefix = string.Empty;
            });
        }
        else
        {
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseRouting();
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }
}

C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll

這是詳細錯誤日志的output:

[aspnetcorev2.dll] Current process bitness type detected as isX64=1
[aspnetcorev2.dll] Processing entry 'C:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] Binary type 6
[aspnetcorev2.dll] Found dotnet.exe via where.exe invocation at 'C:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] Resolving absolute path to hostfxr.dll from 'C:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] hostfxr.dll located at 'C:\Program Files\dotnet\host\fxr\5.0.13\hostfxr.dll'
[aspnetcorev2.dll] Parsed hostfxr options: dotnet location: 'C:\Program Files\dotnet\dotnet.exe' hostfxr path: 'C:\Program Files\dotnet\host\fxr\5.0.13\hostfxr.dll' arguments:
[aspnetcorev2.dll] Argument[0] = 'C:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] Argument[1] = '.\OA.Api.dll'
[aspnetcorev2.dll] c:\b\w\e37dd45d8cd1eaf4\modules\iisintegration\src\aspnetcoremodulev2\commonlib\fileoutputmanager.cpp:142 Operation failed with LastError: 32 HR: 0x80070020
[aspnetcorev2.dll] Event Log: 'Invoking hostfxr to find the inprocess request handler failed without finding any native dependencies. This most likely means the app is misconfigured, please check the versions of Microsoft.NetCore.App and Microsoft.AspNetCore.App that are targeted by the application and are installed on the machine.' 
End Event Log Message.
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at c:\b\w\e37dd45d8cd1eaf4\modules\iisintegration\src\aspnetcoremodulev2\aspnetcore\handlerresolver.cpp:80 
[aspnetcorev2.dll] Event Log: 'Could not find inprocess request handler. Captured output from invoking hostfxr: ' 
End Event Log Message.
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at c:\b\w\e37dd45d8cd1eaf4\modules\iisintegration\src\aspnetcoremodulev2\aspnetcore\handlerresolver.cpp:153 
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at c:\b\w\e37dd45d8cd1eaf4\modules\iisintegration\src\aspnetcoremodulev2\aspnetcore\applicationinfo.cpp:136 
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at c:\b\w\e37dd45d8cd1eaf4\modules\iisintegration\src\aspnetcoremodulev2\aspnetcore\applicationinfo.cpp:91 
[aspnetcorev2.dll] Event Log: 'Failed to start application '/LM/W3SVC/4/ROOT', ErrorCode '0x8000ffff'.' 
End Event Log Message.

幾天來我一直在嘗試用谷歌搜索詳細的錯誤,但到目前為止還沒有找到解決方案的運氣 希望有任何有用的建議

編輯:

我剛剛發現了一些有趣的事情。 If I navigate to my bin folder and open up command prompt I can start the application using the dotnet ApplicationName.dll command it displays the URL in the command prompt.I am then able to navigate to the url in the browser and call my api actions .

仍然不知道為什么它在 Visual Studio 中不起作用。

您只需從屬性中將進程從InProcess設置為OutOfProcess

試試這個供您參考。

正如您所提到的,您可以在 IIS 之外啟動您的應用程序,這看起來像是與 IIS 相關的配置錯誤(理論上,500.0 錯誤可能是任何東西)。 我假設您正在嘗試使用本地 IIS 安裝來運行您的應用程序(不是 IIS Express)。 您是否嘗試在創建主機構建器時添加UseIIS()

出於某種原因,我不得不將 web.config 文件添加到我在 Visual Studio 中的項目中,然后它在 IISExpress 中運行。 這是 web.config 文件,以防有人遇到同樣的問題。 只需將processPath替換為 your.exe 的位置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="bin\Debug\net5.0\OA.Api.exe" arguments="" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
        <handlerSettings>
          <handlerSetting name="debugFile" value=".\logs\aspnetcore-debug.log" />
          <handlerSetting name="debugLevel" value="FILE,TRACE" />
        </handlerSettings>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM