Trying to run an .NET Core web api application in the browser but keep getting the following error:
HTTP Error 500.0 - ANCM In-Process Handler Load Failure
I'm using .NET Framework 5
VS 2019 Community Version 16.11.8
The following .NET Core components have been installed:
- ASP.NET Core Runtime 5.0.13
- ASP.NET Core Hosting Bundle
- .NET Desktop Runtime 5.0.13
AspNetCoreModuleV2 is installed and present under:
Program.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>();
}
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
Here is the output of the detailed error logs:
[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.
I've been trying for days to google the detailed error but no luck so far on getting a resolution Would appreciate any helpful suggestions
Edit:
I've just discovered something interesting. 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.
Still no idea why it's not working in Visual Studio though.