137
votes

I was experimenting with a new feature that comes with .net core sdk 2.2 that is supposedly meant to improve performance by around 400%.

Impressive so I tried it out on my ABP (ASP.NET Boilerplate) project

Template asp.net core mvc 4.0.2.0

I added the following to my web.mv.cproj file

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
  </ItemGroup>

Unfortunately I do not think this version of the ABP framework is compatible as the project simply fails to run and throws: (eventually)

HTTP Error 500.30 - ANCM In-Process Start Failure

I checked the logs after setting stdoutLogEnabled="true" in the web.config and re-trying - but no entries.

Has anybody had any success running the current ABP against a asp.net core in process setup?

I'm thinking this may be something only available in ABP vNext.

30
check whether there is public function which is not having POST attribute. Make it privateMohan
I dont seem to be able to add a post, so ill comment here. My problem started when migrating from core 2.1 to core 3.1, and the issue was with event logs. I hadn't set up the area in the event log for the logging to log tothatOneGuy
Mine problem was I added this code in startup file app.UseFileServer(new FileServerOptions { FileProvider=new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(),"pdfs")), RequestPath="/publish" }); and forget to create pdfs folder thererahularyansharma

30 Answers

158
votes

In ASP.NET Core 2.2, a new Server/ hosting pattern was released with IIS called IIS InProcess hosting. To enable inprocess hosting, the csproj element AspNetCoreHostingModel is added to set the hostingModel to inprocess in the web.config file. Also, the web.config points to a new module called AspNetCoreModuleV2 which is required for inprocess hosting.

If the target machine you are deploying to doesn't have ANCMV2, you can't use IIS InProcess hosting. If so, the right behavior is to either install the dotnet hosting bundle to the target machine or downgrade to the AspNetCoreModule.

Source: jkotalik (Github)

Try changing the section in csproj (edit with a text editor)

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>

to the following ...

 <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
    <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
 </PropertyGroup>

Source (Github)

74
votes

From ASP.NET Core 3.0+ and visual studio 19 version 16.3+ You will find section in project .csproj file are like below-

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

There is no AspNetCoreHostingModel property there. You will find Hosting model selection in the properties of the project. Right-click the project name in the solution explorer. Click properties.

enter image description here

Click the Debug menu.

enter image description here

enter image description here

Scroll down to find the Hosting Model option.

enter image description here

Select Out of Process.

enter image description here

Save the project and run IIS Express.

UPDATE For Server Deployment:

When you publish your application in the server there is a web config file like below:

enter image description here

change value of 'hostingModel' from 'inprocess' to 'outofprocess' like below:

enter image description here

30
votes

In my case I had recently changed a database connection string in my appstettings.json file. Without logging or error catching in place I suspect this error wound up causing the "HTTP Error 500.30 - ANCM In-Process Start Failure" error.

I happened to notice the exchange between x-freestyler and Tahir Khalid where Tahir suggested an IOC problem in startup. Since my startup had not changed recently but my appstettings.json had - I determined that the connection string in my appstettings.json was the cause of the problem. I corrected an incorrect connection string and the problem was solved. Thanks to the whole community.

15
votes

If you are using Visual Studio, and have any instances of it running, close them all.

You should find a .vs sub folder where your Visual Studio solution (.sln file) resides.
Delete the .vs folder and try again with the in-process hosting model.

14
votes

I got the same error on my development machine running Windows 10. The error did not go away after I installed dotnet core hosting bundle. I had to go to Event Viewer to get the detailed error. Your underlying issue (if any) may be different than mine. Point is, if you're on a Windows machine, Event Viewer is there to provide details. Hope this helps someone.

event viewer provided error details

12
votes

ASP.NET Core 2.2 or later: For a 64-bit (x64) self-contained deployment that uses the in-process hosting model, disable the app pool for 32-bit (x86) processes.

In the Actions sidebar of IIS Manager > Application Pools, select Set Application Pool Defaults or Advanced Settings. Locate Enable 32-Bit Applications and set the value to False.

Source: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.0#create-the-iis-site

7
votes

HTTP Error 500.30 – ANCM In-Process Start Failure” is moreover a generic error. To know more information about the error

Go to Azure Portal > your App Service > under development tools open console. We can run the application through this console and thus visualize the real error that is causing our application not to load.

For that put, the name of our project followed by “.exe” and press the enter key.

5
votes

I looked at the Windows Logs under Application. It displayed the error message and stack trace. I found out I was missing a folder called node_modules. I created that folder and that fixed it.

I did not make any changes to web.config or the project file. My .NETCoreApp version was 3.1

4
votes

In may case it was just a typo which corrupts and prevents parsing of JSON settings file

3
votes

Removing the AspNetCoreHostingModel line in .cproj file worked for me. There wasn't such line in another project of mine which was working fine.

<PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
3
votes

I had a similar issue when attempting to switch to from OutOfProcess hosting to InProcess hosting on a .Net Core project which I had recently upgraded from 2.0 to 3.0.

With no real helpful error to go on and after spending days trying to resolve this, I eventually found a fix for my case which I thought I'd share in case it is helpful to anyone else struggling with this.

For me, it was caused by a few Microsoft.AspNetCore packages.

After removing all of the referenced Microsoft.AspNetCore packages that had version less than 3.0.0 (there was no upgrade available >= 3.0.0 for these) this error no longer occurred.

These were the packages I removed;

<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.8" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />

All other Microsoft.AspNetCore packages with version greater than or equal to 3.0.0 worked fine.

3
votes

Download the .NET Core Hosting Bundle installer using the following link:

Current .NET Core Hosting Bundle installer (direct download)

  1. Run the installer on the IIS server.
  2. Restart the server or execute net stop was /y followed by net start w3svc in a command shell.
2
votes

This publish profile setting fixed for me:

Configure Publish Profile -> Settings -> Site Extensions Options ->

  • [x] Install ASP.NET Core Site Extension.
2
votes

I found another issue that starts out giving the same error message as in the question. I am sharing this here so that before changing the project file you can make sure your services are properly registered.

I am also running .netcore 2.2 and was receiving the same error message so I changed project file from InProcess to OutOfProcess as in the selected answer. After that I found the real cause for my issue when I received “Cannot instantiate implementation type” : The cause of this was for me was having:

services.AddScoped<IMyService, IMyService>();

instead of

services.AddScoped<IMyService, MyService>();

Related post: Why am I getting the error "Cannot instantiate implementation type" for my generic service?

2
votes

After spending an entire day fighting with myself on deciding to host my asp.net core application on IIS with InProcess hosting, i am finally proud and relieved to have this solved. Hours of repeatedly going through the same forums, blogs and SO questions which tried their best to solve the problem, i was still stuck after following all the above mentioned approaches. Now here i will describe my experience of solving it.

Step 1: Create a website in IIS

Step 2: Make sure the AppPool for the website has .Net CLR version set to "No Managed Code" and "Enable 32-bit Applications" property in AppPool -> Advanced Settings is set to false

Step 3: Make sure your project is referencing .Net core 2.2

Step 4: Add the following line in your startup.cs file inside ConfigureServices method

services.Configure<IISServerOptions>(options =>
{
     options.AutomaticAuthentication = false;
});

Step 6: Add the following Nuget packages

Microsoft.AspNetCore.App v2.2.5 or greater

Microsoft.AspNetCore.Server.IIS v2.2.2 or greater

Step 7: Add following line to your .csproj file

<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>

Step 8: Build and publish your code (preferably x64 bitness)

Step 9: Make sure you added your website hostname in etc/hosts file

Step 10: Restart World Wide Web Publishing Service

Now test your asp.net core application and it should be hosted using InProcess hosting In order to verify whether your app is hosted using InProcess mode, check the response headers and it should contain the following line

Server: Microsoft-IIS/10.0 (IIS version could be any depeding on your system)

Update: Download and Install ASP.Net Core Hosting Bundle which is required for it to work

1
votes

Resolved my issue by running dedicated App Pool for AspNetCoreModuleV2

Description:

HTTP Error 500.34 - ANCM Mixed Hosting Models Not Supported

I was running multiple applications under the same App Pool. Some of the applications were running

<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />

The application causing the error was running AspNetCoreModuleV2

<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />

I created a new App Pool dedicated for AspNetCoreModuleV2 and it resolved my issue.

1
votes

I encountered this issue on an Azure App Service when upgrading from 2.2 to 3.1. The reason ended up being the "ASP.NET Core 2.2 (x86) Runtime" Extension was installed on the App Service. Removing that extension from Kudu fixed the issue!

1
votes

Wow, there are a lot of answers on this question, but I had this same issue and my solution was different from anything I read here, and also quite simple.

I had been having issues with deploying my app to azure with the right environment settings, so I was messing with the launchsettings.json file, and I had changed the value of the ASPNETCORE_ENVIRONMENT variable in the IIS profile from "Development" to "Production". Changing it back to "Development" fixed the issue for me.

  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
1
votes

Make sure that your *.deps.js json file copied correctly to the deployed location

1
votes

In my case it was a wrong value in appsettings.json file. The value was .\SQLEXPRESS and it worked after i changed it to .\\SQLEXPRESS

1
votes

In my case it was database connection problem. This error needs to be more clear. I hope they will do it in the future. Basically it is a problem at ConfigureServices function in Startup. My advise is try to add all lines try catch in ConfigureServices function and you can findout where is problem.

1
votes

In my case after spending a lots of time the problem was the platform target was x86 and after change it to any CPU the issue fixed. platform target

0
votes

For me it was wrongly injected DBContext in HostedService. I rewrote it according to this:

How should I inject a DbContext instance into an IHostedService?

and all worked fine!

0
votes

Because the application crashes. For whom saving time on this exception!

And the error code says it throws an exception because it can't find a file in the initial phase. See the Environment Settings section. In my scenario, it worked when I changed the following code

var environment = whb.GetSetting("environment");

to

var environment = "Development";// whb.GetSetting("environment");

Because I have appsettings.development.json but I didn't have appsettings.production.json. Why it can't find any file because it's looking for different thing on right place.

0
votes

With .Net Core 2.2 you should be able to use the InProcess hosting model, since it is naturally faster: everything is processed in IIS, without an extra HTTP-hop between IIS and your app's Kestrel server. One thing you might want to do is add this tag: AspNetCoreModuleV2 Notice the new AspNetCoreModuleV2 vs older AspNetCoreModule option. Another important thing to do is, examine Windows Application Event Log, to identify the culprit. Although error messages there may be cryptic, occasionally, they point to the exact line numbers in the code that caused the failure. Also, in case you use CI/CD with TFS, there maybe environment variables in appsettings.json file that were not properly replaced with their designated values, and this was one of the exception sources for me.

0
votes

I had an issue in my Program.cs file. I was trying to connect with AddAzureKeyVault that had been deleted long time ago.

Conclusion:

This error could come to due to any silly error in the application. Debug step by step your application startup process.
0
votes

In my case, I had a migration which was failing when run on a specific environment in Azure, but running fine in dev. As we have the service configured to run the migrations as part of startup, the actual startup of the web app fails.

I ran the migration manually on the environment to discover the problem, then adjusted it to deal with the data differences on that environment.

If anyone knows how I could have seen the migration error without manually running in directly on the DB, that would be useful.

0
votes

I just had the same the same issue. It turned out it was a stupid mistake on my side.

In the ServiceCollection I tried to register an abstract class

services.AddScoped<IMyInterface, MyClasss>();

where MyClass was abstract for some unknown for me reason hehe :)

So guys if you got HTTP Error 500.30 - ANCM In-Process Start Failure Just review your ServiceCollection

0
votes

For me, everything was just fine but the issue was due to publishing by different VS versions, weird !!! (latest VS 2019 (16.4.2)). When I publish the application with VS 2017 it works fine.

The actual issue is in its dependency json file (e.g. MyWebApp.deps.json) in the publish folder. Hope it helps someone.

enter image description here