HTTP 错误 500.35 - 同一进程 ASP.NET Core 3 中的 ANCM 多个进程内应用程序 [英] HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process ASP.NET Core 3

查看:44
本文介绍了HTTP 错误 500.35 - 同一进程 ASP.NET Core 3 中的 ANCM 多个进程内应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从今天早上开始,项目代码没有任何更改,一个非常简单的 Web API,一个控制器和 3 个方法,使用 Swagger,它不再启动,我收到错误:

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 错误 500.35 - ANCM 多个进程内应用程序在同一进程中

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

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

Event viewer report the most useless message:

IIS Express AspNetCore Module V2:启动应用程序失败'/LM/W3SVC/2/ROOT/docs',错误代码 '0x80004005'.

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

多次重启系统.

我使用的是 Visual Studio 2019,应用程序成功编译,几分钟前它运行良好.未安装新软件,未添加任何软件包.也尝试过清理和重建.

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.

我能做什么?

net core 还是太不稳定不能专业使用吗?

Is net core still too unstable to be used professionally?

更新

从相同版本的 Visual Studio 启动但在另一台 PC 中运行的相同代码.

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

更新 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:

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

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

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

推荐答案

感谢 @Lex Li 他有给了我解决方案.

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

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

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.

对于 Visual Studio 2019,此文件位于

For Visual Studio 2019, this file is located in

$(solutionDir).vs{projectName}configapplicationhost.config

对于其他版本,请查看此帖子:​​IIS 在哪里找到快速配置/元数据库文件?

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

在我有以下部分:

<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:ProjectsMyProjectName" />
    </application>

   <application path="/docs" applicationPool="docs AppPool">
      <virtualDirectory path="/" physicalPath="E:ProjectsMyProjectName" />
    </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%MicrosoftIISExpressLogs" 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:ProjectsMyProjectName" />
</application> 

当我尝试将/docs 路径设置为起始文件夹时,这肯定已添加.

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

注释掉此设置以及与此路径相关的文件末尾的另一个设置已解决了问题.

这篇关于HTTP 错误 500.35 - 同一进程 ASP.NET Core 3 中的 ANCM 多个进程内应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆