I have recently updated my site on IIS with changes that I made, with the update I did not do any nuget package upgrades or added any new assemblies to the project but I am now getting the following error when I browse any page
I checked first in event log and I found the following error
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.
I found a few answers on the error code but all of them was to the version of DotNetCore installed which is not the solution to my problem. I have done further testing and added a try catch over my code like follow:
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);
}
}
}
The above code has given me the following error
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)
I have reverted back to the old code and the error went straight away, however when I compare the installed version of System.Runtime.InteropServices.RuntimeInformation it is the same version on both old and new (with the changes)
I have tried the solution stated in the link
Could not load file or assembly '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>