123

From this morning without any changes to the code of the project, a very simple Web API, one controller and 3 methods, with Swagger, it doesn't start anymore and I get the error:

HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process

Event viewer report the most useless message:

IIS Express AspNetCore Module V2: Failed to start application '/LM/W3SVC/2/ROOT/docs', ErrorCode '0x80004005'.

Restarted the system several times.

I'm using Visual Studio 2019, the application successfully compile and a few minutes ago it was working fine. No new software has been installed, no packages added. Tried also clean and rebuild.

I've just modified the comment of a method. Obviously I've tried also to restore the previous comment but I get always the same message.

What can I do?

Is net core still too unstable to be used professionally?

UPDATE

The same code launched from the same version of Visual Studio but in another PC runs properly.

UPDATE 2

Below the code of the application:

startup.cs

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using System;
using System.IO;
using System.Reflection;

namespace WFP_GeoAPIs
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {

            services.AddControllers(); 
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo() { Title = "Geographic APIs", Version = "v1.0.0" });
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.XML";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);    
                c.IncludeXmlComments(xmlPath);
            });
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(
                 Path.Combine(Directory.GetCurrentDirectory(), "swagger-ui")),
                RequestPath = "/swagger-ui"
            });

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();

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

            app.UseSwagger();    
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "GeoAPIs Ver 1.0.0");
                c.RoutePrefix = "docs";
                c.InjectStylesheet("/swagger-ui/custom.css");
            });
        }
    }
}

Here is the launchsettings.json:

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": {
      "applicationUrl": "http://localhost:51319",
      "sslPort": 44345
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "docs",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "WFP_GeoAPIs": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "docs",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

but coping the project on another PC with the same Visual Studio version works fine, so it looks like the is a configuration bug in the .NET Core or VIsual Studio property...

Giox
  • 4,785
  • 8
  • 38
  • 81
  • 3
    .NET Core is in use in production by many developers, including Microsoft itself. It is perfectly stable. The problem is on your side. However, there's not enough here to help you. Check the troubleshooting guide in docs. – Chris Pratt Oct 05 '19 at 11:01
  • 1
    I'm getting the same error. Are you using a web.config? – Marcel Oct 05 '19 at 12:25
  • @Marcel no I'm not using it – Giox Oct 05 '19 at 13:08
  • 2
    I do, i fixed mine by changing AspNetCoreModuleV2 to AspNetCoreModule, in the web.config. – Marcel Oct 05 '19 at 13:11
  • @Marcel thanks I'll give it a try but I want to understand where is the bug and why it sees two applications running on the same application pool (launched by Visual Studio) – Giox Oct 05 '19 at 13:47
  • @ChrisPratt What info could be relevant to give me a direction? – Giox Oct 05 '19 at 13:54
  • Honestly i don't know. I'm using a hosting that i don't have access directly to the server. This article seems to explain it: http://www.binaryintellect.net/articles/bb086279-ed2a-4628-85f2-7e91125fbe57.aspx - they also suggest a solution – Marcel Oct 05 '19 at 14:31
  • @Marcel I'm on Visual Studio, development environment, IIS is launched and managed by Visual Studio, is a different environment. The bug is in Visual Studio 2019 (16.3) and ASP.NET Core 3.0 – Giox Oct 05 '19 at 14:44
  • 6
    You need to review the actual configuration file used by VS/IIS Express to see if by mistake two .NET Core apps go to the same pool. In-process model cannot support that. – Lex Li Oct 05 '19 at 15:09
  • 5
    @Chris : Their frustration with this interaction is warranted, IMO. I touched my project launch settings using the project settings -> debug UI. I edited the wrong thing, (also IMO) because the UI is flawed and the "App URL" is easy to mistake for the "Launch browser" setting. *Worse*, I reverted my change but the problem persisted in a file I never touched (discussed below). Cleaning and rebuilding does not repair that file. Deleting the config does not repair the file. Deleting the .vs folder *does* resolve it, but removes debugger and other personalization in the process. – shannon Nov 04 '19 at 18:24
  • Just create another application pool for your other website. – L.Gonzales Jun 03 '21 at 05:52

15 Answers15

223

It's currently a bug in VS2019 - (Nov 4 '2019)

1.) Close your solution

2.) Delete applicationhost.config in folder .vs or delete the whole .vs folder.

The .vs folder is a hidden folder and is next to your solution file usually.

enter image description here

3.) Restart your solution again

Legends
  • 21,202
  • 16
  • 97
  • 123
  • 4
    Thanks, this saves the hassle of pouring over applicationhost.config. – BitsAndBytes Nov 18 '19 at 15:09
  • 4
    Fixed it for me. This seems to fix a lot of similar issues... – Rob L Dec 23 '19 at 03:50
  • This is the one which worked for me. Again my issue was during debugging. – Abi P Mar 20 '20 at 15:28
  • 4
    My Hero! This has plagued me for days! – Godrules500 Mar 27 '20 at 14:05
  • 2
    A slight variation for me: I searched for `applicationhost.config` in Windows Explorer first. Then closed Visual Studio. Noticed that the file auto-deleted. Restarted VS and worked again. Also note the `.vs` folder is a hidden folder. – Jason Snelders May 09 '20 at 05:47
  • 1
    Wow. That's nasty. Thanks! – Fetchez la vache Jun 11 '20 at 14:59
  • Well informed succinct answer; so much better than the lazy sledgehammer approach of "delete .vs/bin/obj folders" – Rab Oct 05 '20 at 10:17
  • 3
    Still a bug in Dec 2020 and this still fixed it. Thanks. – Fordy Dec 07 '20 at 14:02
  • 1
    Happened to me today with vs 16.8.6. And this fixed it. Thank you! (And judging from some other comments, this is the first thing I'll try whenever anything wierd happens.) – Peter Feb 24 '21 at 17:20
  • thanks. Amazing that this issue has not be resolved. Please fix it. – Golden Lion May 07 '21 at 16:11
  • I removed the "applicationhost.config" file and as mentioned, and it solved my problem, thank you very much!!! – Gabriel Santos Reis Aug 12 '21 at 12:06
  • 1
    I like the comment made by @Chris Pratt in the original question: ".NET Core is in use in production by many developers, including Microsoft itself. It is perfectly stable. The problem is on your side." Two years on, the problem is still at large. So much for the comment, and the "stability", thanks very much. This solution saved the bacon. – pengu1n Aug 16 '21 at 07:40
  • This problem just happened to me in latest VS2019 in Oct 2021. After using Visual Studio for the last 15 years or so, I've come to the conclusion the REAL reason MS pushes out a new version of Visual Studio every few years is the existing version gets to be too buggy to attempt to fix! – Mmm Oct 13 '21 at 20:41
  • Just had this bug on VS 2022 (17.0.0) launched yesterday. Deleting the .vs folder fixed it. – dperez Nov 10 '21 at 16:01
  • 1
    Confirmed this still happens in VS 2022, and deleting .vs fixes it. – Mmm Jan 03 '22 at 20:50
  • Best solution - after hours waste debugging I found it. Thanks! – Владимир В May 05 '22 at 11:47
53

Thanks to @Lex Li he has given me the solution.

The issue was in the applicationhost.config, the metabase file containing all the settings for the IISExpress launch by Visual Studio to run your web application.

For Visual Studio 2019, this file is located in

$(solutionDir)\.vs\{projectName}\config\applicationhost.config

For other version check this post: Where is the IIS Express configuration / metabase file found?

under the section I had the following:

<sites>    
  <site name="WebSite1" id="1" serverAutoStart="true">
    <application path="/">
      <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation=":8080:localhost" />
    </bindings>
  </site>

  <site name="MyProjectName" id="2">
    <application path="/" applicationPool="MyProjectName AppPool">
      <virtualDirectory path="/" physicalPath="E:\Projects\MyProjectName" />
    </application>

   <application path="/docs" applicationPool="docs AppPool">
      <virtualDirectory path="/" physicalPath="E:\Projects\MyProjectName" />
    </application>

    <bindings>
      <binding protocol="http" bindingInformation="*:59386:localhost" />
      <binding protocol="https" bindingInformation="*:44345:localhost" />
    </bindings>
  </site>
  <siteDefaults>
    <!-- To enable logging, please change the below attribute "enabled" to "true" -->
    <logFile logFormat="W3C" directory="%AppData%\Microsoft\IISExpressLogs" enabled="false" />
    <traceFailedRequestsLogging directory="%AppData%\Microsoft" enabled="false" maxLogFileSizeKB="1024" />
  </siteDefaults>
  <applicationDefaults applicationPool="Clr4IntegratedAppPool" />
  <virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>

Where there are some strange setting defined by

<application path="/docs" applicationPool="docs AppPool">
   <virtualDirectory path="/" physicalPath="E:\Projects\MyProjectName" />
</application> 

that has been certainly added when I've tried to set as start folder the /docs path.

Commenting out this setting and another one at the end of the file related to this path has solved the issue.

Giox
  • 4,785
  • 8
  • 38
  • 81
  • 5
    You are livesaver ! +1 I just deleted .vs folders for my project and now it is working (both folders for solution and project) Thanks – Siarhei Kavaleuski Oct 10 '19 at 00:31
  • 1
    I had the same issue and this fixed it, however, I noticed that the second entry was added automatically by VS when I modified the "applicationUrl" property under iisExpress in launchSettings.json. Not sure why this would happen. – Richie Oct 18 '19 at 15:18
  • @Richie it seems that's a bug with VS. It isn't deleting the older apps when you change the URL, which it should be when the app runs inprocess. There's a report here: https://developercommunity.visualstudio.com/content/problem/699245/applicationhostconfig-not-remove-old-virtualdirect.html. Let's see if it's not closed as Lower Priority. – andre_ss6 Oct 25 '19 at 20:21
  • Just ran into this on VS2022 in Jan 2022 and deleting .vs/config/applicationhost.config and restarting VS fixed it. – ssmith Jan 21 '22 at 03:27
41

I got the same error when I did the following:

  1. Published two separate asp.net core websites
  2. In IIS, created two websites under "Default Web Site", each having physical path set to each of the publish folders in (1) respectively.
  3. Now whichever of the sites I open first works, and the second gives that error.

Problem:

Since both my sites are under "Default Web Site" they are both using DefaultAppPool, which is the cause of this error. The same error occurs when the sites are not under "Default Web Site" but use the same app pool.

Solution:

As mentioned in the docs,

To fix this error, run apps in separate IIS application pools.

for me this problem was resolved when I started using separate app pools for each site.

Sнаđошƒаӽ
  • 16,753
  • 12
  • 73
  • 90
  • I use a host that only provides a single app pool. Is there a way to run two Core sites within the same app pool? – Francisco d'Anconia Jul 27 '20 at 19:11
  • You should be able to set the two core sites to use the same app pool. A quick search should give you plenty articles. [Here's one](https://hostadvice.com/amp/how-to/how-to-change-an-application-pool-for-an-application-in-iis-7/). – Sнаđошƒаӽ Jul 27 '20 at 19:42
  • 2
    I was able to resolve this issue by using out-of-process mode. This allowed hosting both within the same app pool – Francisco d'Anconia Aug 04 '20 at 20:40
  • This is correct : To fix this error, run apps in separate IIS application pools. Run on .net core 3.1 with hosting bundle, and run on IIS windows 11 – toha Nov 09 '22 at 13:38
15

I fixed the issue by deleting V2 in web.config file generated after publishing the solution.

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

instead of

<handlers>
    <add name="aspNetCore" path="*" verb="*"
        modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
SimplyInk
  • 5,832
  • 1
  • 18
  • 27
Michel El Hajj
  • 184
  • 3
  • 13
5

I had the same problem.

Add this line in .csproj file in Tag: <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>

Although it is the 500.30 error it also fixed the 500.35 problem.

HTTP Error 500.30 - ANCM In-Process Start Failure

I hope help you.

Best regards.

Federico
  • 81
  • 2
  • 7
3

In .csproj file, set:

<PropertyGroup>
   ...
   <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

Allow host the same pool

Diego Venâncio
  • 5,698
  • 2
  • 49
  • 68
1

If you see this error (HTTP Error 500.35 - Multiple In-Process Applications in same Process ASP.NET Core 3) after deploying your application to a server (in house or 3rd party hosting provider), it could be that the relevant module is not installed on the host server.

In my case, it didn't have AspNetCoreModuleV2 and I had to update the web.config from:

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

to:

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

Alternatively, this can also be set in the .csproj file as follow:

<PropertyGroup>
    <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
</PropertyGroup>
Alex Sanséau
  • 8,250
  • 5
  • 20
  • 25
1

According to the ASP.NET Core, Out-of-process hosting with IIS and ASP.NET Core article:

1) Go to the Startup.cs. In the ConfigureServices:

services.Configure<IISOptions>(options =>
{
     options.ForwardClientCertificate = false;
});

2) Go to the: "Properties" folder > "PublishProfiles" folder > "Web Deploy.pubxml" file. To configure an app for out-of-process hosting, set the value of the <AspNetCoreHostingModel> property to OutOfProcess:

<PropertyGroup>
     <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

3) Publish your project again.

Kamil Guliyev
  • 108
  • 1
  • 1
  • 8
0

The Most Easy And Reliable think which worked for me is , just simply put a simple index.html in main application , and treat every application in your solution as subapplications.

0

In my case it got fixed just switching Application pool to .NET v2.0 enter image description here

Usman Ali Maan
  • 368
  • 2
  • 12
0

enter image description here

Change from inprocess to OutOfprocess in Web.config

Ali Esam
  • 1
  • 2
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/30139334) – kubatucka Oct 21 '21 at 17:25
0

ASP.Net Core 6, after publishing edit the web.config file, and change hostingModel="InProcess" to hostingModel="OutofProcess"

<system.webServer>
  <handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
  </handlers>
  <aspNetCore .... hostingModel="OutOfProcess" stdoutLogFile=".\logs\stdout" />
</system.webServer>

I've left the modules as V2, and it worked.

Fandango68
  • 4,461
  • 4
  • 39
  • 74
0

In my case it was because of Dependency Injection (.Net Core 3.1). I had used ILogger but missed to provide the Type ILogger<type> logger in the constructor injection. I had just provided ILogger logger resulting in the "HTTP Error 500.30 - ANCM In-Process Start Failure" shown while running the API.

Tried looking through Event Viewer logs as per suggestions but in vain :(.

Finally looked at VS Output window for clues and found this "Exception thrown: 'System.AggregateException' in Microsoft.Extensions.DependencyInjection.dll"

I recollected the recent changes and went ahead and provided the type in the constructor and it worked fine.

Viru
  • 1
  • 1
0

If the hosted application is .Net Core 3.1, use the new App Pool.

According to the asp.net core, In-process hosting model article shows:

Sharing an app pool among apps isn't supported. Use one app pool per app.

The idea is you have to use one app pool for one application. Please do not share one app pool with multiple applications.

shalitha senanayaka
  • 1,905
  • 20
  • 37
-2

in the .csproj file you can add OutOfProcess:

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

and this will generate this (on publish) in the web.config:

<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\WebApplication3.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
</configuration>

note the OutOfProcess,

an alternative would be to remove the V2 from the web.config

Omu
  • 69,856
  • 92
  • 277
  • 407