System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=, Culture=neutral

Question: How do you solve the error in IIS that says:

Category: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer
EventId: 2

Connection ID "18302628899323904004", Request ID "(null)": An unhandled exception was thrown by the application.

System.IO.FileNotFoundException:'>#f8cac6;">System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime.CompilerServices.Unsafe, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Microsoft.AspNetCore.HttpSys.Internal.RequestHeaders.PropertiesTryGetValue(String key, StringValues& value)
   at Microsoft.AspNetCore.HttpSys.Internal.RequestHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.get_Item(String key)
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.CheckRequestCanHaveBody()
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.InitializeContext()
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

Login to See the Rest of the Answer


[Scenerial 1]: If you happened to have restored all the Nuget Packages in the Project.csproj manually, there is a chance that you defined or typed a wrong version of the Microsoft.Extentions.Configuration.Abstructions and Microsoft.Extensions.Configuration. If the package version is downgraded or is not in sync with the version of Microsoft.Extensions.Configuration this might create errors in IIS.

Ways to resolve the error.

1. Make sure that if you have more than one project in the Solution, only include the packages mentioned in the

.Net 7

© 2024 - ErnesTech - Privacy
E-Commerce Return Policy