繁体   English   中英

Windows 10 Visual Studio 2019 IIS Express 无法启动并出现错误 500

[英]Windows 10 Visual Studio 2019 IIS Express won't start with error 500

我们在.Net Core 3.1 中有一个 API 项目。 它在团队中的所有计算机上都可以工作,但是当尝试在新成员计算机上调试它时失败了。 它指出存在服务器错误(500)并且不会启动程序。 它作为本地服务工作,没有 IIS。

VS 错误 事件日志错误

我们试图格式化计算机并重新开始,但没有用。 我看到了与项目配置和启动设置相关的帖子,但由于它正在其他机器上运行,我认为这不是问题。 我们还尝试在 iis 模板文件和其他地方推荐的 dll 中添加 aspnetcore 模块所需的行,得到同样的问题。

任何建议将不胜感激!


来自 HttpFailure_08-24-17.tml 文件的错误文本

注意:您确实应该复制/粘贴为文本,而不是附加屏幕截图:

The description for Event ID 1034 from source IIS Express AspNetCore Module V2 cannot found.  
Either the component that raises this event is not installed on your local computer or the installation is corrupted. 
You can install or repair the component on the local computer.
... 
The following information was included with the event:

Could not load configuration. Exception message: Unable to get required configuration section 'system.webServer/aspNetCore'.  Possible reason is web.config authoring error.

The request is not supported.

编辑:Program.cs:

 public class Program
{
    public static void Main(string[] args)
    {
        try
        {
            Console.Error.WriteLine("Starting application (from error log without errors)");

            var config = new ConfigurationBuilder().AddEnvironmentVariables("ASPNETCORE_").Build();

            Console.WriteLine("Config set");

            var hostBuilder = new WebHostBuilder()
                .UseKestrel(opt => opt.AddServerHeader = false)
                .UseConfiguration(config)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>();

            Console.WriteLine("hostBuilder set");

            // ConfigureServices is only used to delay execution until UseIISIntegration()
            // has actually set the "urls" setting.

            Console.WriteLine("urls for hostBuilder " + hostBuilder.GetSetting("urls"));

            hostBuilder.ConfigureServices(services =>
            {
                var urls = hostBuilder.GetSetting("urls");
                urls = string.IsNullOrWhiteSpace(urls) ? "127.0.0.1" : urls.Replace("localhost", "127.0.0.1");
                hostBuilder.UseSetting("urls", urls);
            });

            Console.WriteLine("hostBuilder.ConfigureServices set");

            var host = hostBuilder.Build();

            Console.WriteLine("host set");

            host.Run();

        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex.Message);
        }
    }
}

该错误警告您AspNetCore Module V2已损坏或丢失。

需要在 IIS 中安装一个模块才能与 AspNetCore 项目兼容(特别是与默认的 Kestrel 服务器一起使用)。

您需要按照这些说明安装此模块。 据我所知,它不需要任何额外的配置。

编辑:

我偶然发现了这篇文章,其中提到他们也遇到了 IIS Express 的问题。 也许它可以对您有所帮助,并按照他们的指南找出您的配置中有什么问题?

https://blog.maartenballiauw.be/post/2019/02/26/asp-net-core-iis-express-empty-error-starting-application.html

似乎我们有一个防病毒软件导致 Visual Studio 2019 安装出错,破坏了 netcoreapp.dll 等。 我将关闭此声明,说明在关闭防病毒软件并继续安装后,@Sotiris Koukios-Panopoulos 的博客文章起到了作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM