1

我最近在 IIS 上用我所做的更改更新了我的网站,更新后我没有做任何 nuget 包升级或向项目添加任何新程序集,但是当我浏览任何页面时现在出现以下错误 在此处输入图像描述

我首先检查了事件日志,发现以下错误

Application 'MACHINE/WEBROOT/APPHOST/WWW.N1CORE.CO.ZA' with physical root 'C:\Websites\beta.n1plus.co.za\' failed to start process with commandline 'C:\Websites\beta.n1plus.co.za\n1Plus.n1Plus.Web.Host.exe ', ErrorCode = '0x80004005 : e0434352.

我在错误代码上找到了一些答案,但所有答案都是安装的 DotNetCore 版本,这不是我问题的解决方案。我已经做了进一步的测试,并在我的代码上添加了一个 try catch,如下所示:

public class Program
{
    public static void Main(string[] args)
    {
        try
        {
            var host = new WebHostBuilder()
                .UseKestrel(opt => opt.AddServerHeader = false)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
        catch (System.Exception ex)
        {
            System.Console.WriteLine(ex.Message);
            System.Console.WriteLine(ex.StackTrace);
        }
    }
}

上面的代码给了我以下错误

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at n1Plus.n1Plus.Web.Startup.Program.Main(String[] args)

我已经恢复到旧代码并且错误立即消失了,但是当我比较 System.Runtime.InteropServices.RuntimeInformation 的安装版本时,它在新旧版本上都是相同的(有更改)

我已经尝试了链接中所述的解决方案

无法加载文件或程序集'System.Runtime.InteropServices.RuntimeInformation

<dependentAssembly>
 <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
 <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
4

0 回答 0