We have 2 projects hosted on IIS: Blazor WebAssembly site and authorization web service. Web service is hosted on Default Web Site, Blazor project as a separate site. Each has it's own app pool ('No managed code'). Both are .NET6 using EF Core. They do not reference each other.
Recently I updated packages in Blazor project to latest versions. After publishing that change our web serivce started throwing:
An unhandled exception has occurred while executing the request.
System.TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Abstractions, Version=6.0.6.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.EntityFrameworkCore.Abstractions, Version=6.0.6.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder..cctor()
EntityFrameworkCore libraries on that web serivce are of version 6.0.5. Our Blazor site was moved to 6.0.6. How can one affect the other?
They are both published by Jenkins as self-contained without trimming, then copied to server.
Web service does not reference Microsoft.EntityFrameworkCore.Abstractions
directly, but I can see it down the line of package refences for EF Core.
I can see the relevant library in the physical folder on server, it's of expected version 6.0.5.
Still, web server throws on any GET, with Swagger or via the Blazor site.
CodePudding user response:
There are many reasons for this error, you can try below methods:
Restart the server to reload everything again, check if site works.
Change 'Enable 32-bit application' from false to true in the advanced settings of the application pool.
Change the identity of the AppPool that your app is using to NetworkService.
IIS > Application Pools > Select current app pool > Advance Settings > Identity.
Grant
IIS_IUSRS
full access to theMicrosoft.EntityFrameworkCore.Abstractions
.