HTTP错误500.35-同一进程ASP.NET Core 3中的ANCM多个进程内应用程序


34

从今天早上开始,没有对项目代码进行任何更改,一个非常简单的Web API,一个控制器和3个方法以及Swagger,它不再启动,并且出现错误:

HTTP错误500.35-同一进程中的ANCM多个进程内应用程序

事件查看器报告最无用的消息:

IIS Express AspNetCore模块V2:无法启动应用程序'/ LM / W3SVC / 2 / ROOT / docs',错误代码'0x80004005'。

重新启动系统几次。

我正在使用Visual Studio 2019,该应用程序已成功编译,几分钟前它运行良好。没有安装新软件,没有添加软件包。也尝试过清理和重建。

我刚刚修改了方法的注释。显然,我也尝试过恢复以前的评论,但总是收到相同的消息。

我能做什么?

网核是否仍然不稳定以致无法专业使用?

更新

从同一版本的Visual Studio启动的相同代码在另一台PC上正常运行。

更新2

在应用程序代码下方:

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");
            });
        }
    }
}

这是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"
      }
    }
  }
}

但是在具有相同Visual Studio版本的另一台PC上处理项目的效果很好,因此看起来是.NET Core或VIsual Studio属性中的配置错误...


1
许多开发人员(包括Microsoft本身)正在将.NET Core用于生产中。它是完全稳定的。问题就在你这边。但是,这里没有足够的帮助您。查看文档中的故障排除指南。
克里斯·普拉特

我遇到了同样的错误。您是否正在使用web.config?
马塞尔(Marcel)

@Marcel不,我不使用它
Giox

1
我确实通过在web.config中将AspNetCoreModuleV2更改为AspNetCoreModule来修复了我的问题。
马塞尔(Marcel)

2
您需要查看VS / IIS Express使用的实际配置文件,以查看是否错误地将两个.NET Core应用程序移至同一池。进程内模型不能支持这一点。
Lex Li

Answers:


50

当前是VS2019中的错误 -(2019年11月4日)

1.)关闭您的解决方案

2)删除applicationhost.config的文件夹.vs 删除整个.vs文件夹

.vs文件夹通常位于您的解决方案文件旁边。

在此处输入图片说明

3.)再次重新启动您的解决方案


谢谢,这省去了倾倒applicationhost.config的麻烦。
CINCHAPPS

1
为我修复它。这似乎解决了许多类似的问题...
Rob L

这是为我工作的那个。同样,我的问题是在调试期间。
Abi P

1
我的英雄!这困扰了我好几天!
Godrules500

这绝对有效:)
阿米特·飞利浦

28

感谢@Lex Li,他给了我解决方案。

问题出在applicationhost.config中,该元数据库文件包含Visual Studio为运行Web应用程序而启动IISExpress的所有设置。

对于Visual Studio 2019,此文件位于

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

对于其他版本,请查看以下文章:IIS Express配置/元数据库文件在哪里?

在该部分下,我有以下内容:

<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>

在哪里定义了一些奇怪的设置

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

当我尝试将/ docs路径设置为开始文件夹时,肯定已经添加了该文件。

注释掉该设置,并在文件末尾与此路径相关的另一个设置解决了该问题。


5
你是救命稻草!+1我刚刚为我的项目删除了.vs文件夹,现在它正在运行(用于解决方案和项目的文件夹)感谢
tscissors 19-10-10

1
我遇到了同样的问题,并已解决,但我注意到,当我在launchSettings.json的iisExpress下修改“ applicationUrl”属性时,VS自动添加了第二个条目。不知道为什么会这样。
Richie

@Richie似乎是VS的错误。当您更改URL时,它并不会删除旧的应用程序,应该在应用程序进程内运行时删除它。这里有一个报告:developercommunity.visualstudio.com/content/problem/699245/…。让我们看看它是否未作为低优先级关闭。
andre_ss6

18

执行以下操作时出现相同的错误:

  1. 发布了两个单独的asp.net核心网站
  2. 在IIS中,在“默认网站”下创建了两个网站,每个网站的物理路径分别设置为(1)中的每个发布文件夹。
  3. 现在,我打开的任何一个站点都可以运行,而第二个站点都可以显示该错误。

问题:

由于我的两个站点都在“默认网站”下,因此它们都使用DefaultAppPool,这是导致此错误的原因。当这些站点不在“默认网站”下但使用相同的应用程序池时,会发生相同的错误。

解:

文档中所述,

要解决此错误,请在单独的IIS应用程序池中运行应用程序。

对我来说,当我开始为每个站点使用单独的应用程序池时,此问题已解决。


2
它起作用了,而不是其他。谢谢。
埃尔多安
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.