Search code examples
c#.net-3.0

Could not load type from assembly in .Net Core 3.0


I updated my .net core application's (MVC web app) target framework from v2.2 to v3.0 and it won't start anymore. I updated all nuget packages that are in my app, and removed the ones that were not needed anymore. Now I am getting this error when trying to start the app. There are no build errors.

TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.Internal.FileResultExecutorBase' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.3.0

There are no references to FileResultExecutorBase in this project and when running dotnet --include-transitive I didn't find any dependencies to Microsoft.AspNetCore.Mvc.Internal. I have tried different things to Startup's ConfigureServices and Configure, but the error stays the same.

These are my packages now, copied from csproj-file:

-EPPlus.Core Version "1.5.4"  
-Microsoft.AspNetCore.Authentication.OpenIdConnect Version "3.0.0"  
-Microsoft.AspNetCore.Identity.EntityFrameworkCore Version "3.0.0"  
-Microsoft.AspNetCore.Mvc.NewtonsoftJson Version "3.0.0"  
-Microsoft.AspNetCore.SpaServices Version "3.0.0"   
-Microsoft.Extensions.Logging.Debug Version "3.0.0"  
-Newtonsoft.Json Version "12.0.3" 
-React.AspNet Version "5.2.4"

Also from csproj-file:

-TargetFramework: netcoreapp3.0  
-Sdk="Microsoft.NET.Sdk.Web" 

I tried to remove that EPPlus.Core package (it's deprecated) and rebuild without it, but as a result was still the same error.


Solution

  • What happened was that this project had dependency to another project (call it B) within the same solution. Project B has target framework of .NET Standard 1.6. Project B is run with this project and it uses class 'Microsoft.AspNetCore.Mvc.Internal.FileResultExecutorBase'.