0
votes

When I run an ASP.NET Core MVC I get the following:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

2

2 Answers

2
votes

Cause: Corrupted NugGet cache, for example browserlink (see this GitHub issue or this GitHub issue )

Solution: Delete the NuGet cache and run dotnet restore. The .nuget/packages directory is in the user's home directory on all operating systems (for example, /home/user1 on Linux or C:\Users\user1 on Windows).

0
votes

I encountered this same error after opening a project in VS 2017 that was initially coded and successfully run using VS Code.

Solution: Generate a solution file for use by VS 2017. Using the integrated terminal in VS Code:

dotnet new sln
dotnet sln add myproj.csproj
dotnet restore

Then open the newly generated sln file in VS 2017. Deeper discussion of this here.