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

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

问题描述

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

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

我该怎么办?

网络核心仍然太不稳定而无法专业使用吗?

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

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 给我解决方法.

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

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}\config\applicationhost.config

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

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> 

当我尝试将/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天全站免登陆