ASP.NET 核心 1.1 HTTP 错误 502.5 - 启动过程失败

ASP.NET core 1.1 HTTP Error 502.5 - Process Failure on startup

当我尝试在我的服务器上启动 ASP.NETcore 1.1 时,出现错误:

HTTP Error 502.5 - Process Failure

Common causes of this issue:

The application process failed to start The application process started but then stopped The application process started but failed to listen on the configured port

我检查了事件查看器。

Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileLoadException at MyApp.Program.Main(System.String[])

MyApp.Program.Main

public class Program
    {
        public static void Main(string[] args)
        {
            Console.Title = "IdentityServer";

            var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls("http://localhost:5000")
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
    }

这是基于 Identity Server 4 代码。

Stdout

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting, Version=1.1.0.0

我已通过 NuGet 添加 Microsoft.AspNetCore.Hosting 到我的项目中。 Microsoft.AspNetCore.Hosting.dll 在我发布的文件中...

在进行更多挖掘后,我发现了这个 post Can't load Microsoft.AspNetCore.Hosting 1.1.0.0 #1826。它建议删除 app.AddBrowserLink();AddBrowserLink() 在我的代码中根本没有使用。

通过注释掉代码,当我引用一个依赖于传统 .NET 的非 .NET Core 项目时,似乎会出现错误。

我正在使用 Visual Studio 2017.

Hansleman 从他的 post How to reference an existing .NET Framework Project in an ASP.NET Core 1.0 Web App 中得到了答案。

我创建了一个指向 .NET Core 的 ASP.NET Core 1.1 应用程序。 我将我的网站重新创建为 ASP.NET Core 1.1,并将其指向 .NET Framework,然后指向失败的代码 运行。