Sudden unexplained build failure: "Could not load file or assembly 'System.Runtime, Version=6.0.0.0"

Chris Guin 0 Reputation points
2026-01-07T21:42:27.1633333+00:00

Having a weird issue all of a sudden - my visual studio 2022 solution refuses to build, as several projects suddenly and unaccountably report similar errors, looking like this:

The "ResolvePackageAssets" task failed unexpectedly. System.TypeInitializationException: The type initializer for 'NuGet.ProjectModel.JsonUtility' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at NuGet.ProjectModel.JsonUtility..cctor() --- End of inner exception stack trace --- at NuGet.ProjectModel.JsonUtility.UseNewtonsoftJsonForParsing(IEnvironmentVariableReader environmentVariableReader, Boolean bypassCache) at NuGet.ProjectModel.LockFileFormat.Read(Stream stream, ILogger log, String path, IEnvironmentVariableReader environmentVariableReader, Boolean bypassCache, LockFileReadFlags flags) at NuGet.ProjectModel.LockFileUtilities.<>c__DisplayClass1_0.<GetLockFile>b__0(FileStream stream, String path) at NuGet.Common.FileUtility.SafeReadT at NuGet.ProjectModel.LockFileUtilities.GetLockFile(String lockFilePath, ILogger logger, LockFileReadFlags flags) at Microsoft.NET.Build.Tasks.LockFileCache.LoadLockFile(String path) at Microsoft.NET.Build.Tasks.LockFileCache.GetLockFile(String path) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task) at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups() at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore() at Microsoft.NET.Build.Tasks.TaskBase.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

At the same time, Visual Studio setup executable fails to run silently. No amount of cleaning, rebuilding, deleting caches, deleting bin/obj/packages folders, or restarting visual studio has helped so far. Installing .NET SDK 6 has not helped (and I didn't need it before, when it built successfully - and the projects in question didn't change at all - so why?)

The precipitating incident seems to have been swapping between git branches across an attempt to upgrade my project from .net framework 4.6.2 to .net core 8. I have swapped branches without issue many times before, but now the build is in a bad state regardless of branch (and the projects with the error were unaffected by the upgrade - one of them is .net core 5, one of them is .netstandard 2.0, etc.)

Running "dotnet nuget locals all --clear" did not help either.

Any other ideas? Anyone seen something like this before? Thank you so much for any help! I am dead in the water without being able to build my projects!

Developer technologies | .NET | .NET Runtime
{count} votes

2 answers

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 4,420 Reputation points Microsoft External Staff
    2026-01-08T11:40:14.16+00:00

    Thank you for reaching out.

    This issue is not caused by your project or any recent code changes. The failure is happening before the build even reaches your code.

    During the build, Visual Studio runs an internal NuGet step (ResolvePackageAssets). That step relies on Visual Studio and .NET build tooling being in a healthy state. In your case, the tooling cannot load the required System.Runtime 6.0 assembly, which indicates the Visual Studio / .NET build environment on the machine is corrupted or partially updated.

    Because this is an environment issue, actions like cleaning the solution, deleting bin/obj, clearing NuGet caches, switching branches, or reinstalling individual .NET SDKs do not resolve it.

    What you should do next

    1. Try repairing Visual Studio
      • Open Visual Studio Installer
      • Select your Visual Studio 2022 installation
      • Choose Repair
      • Restart the machine and try building again
    2. If the installer fails to launch or repair does not help
      • Remove Visual Studio using InstallCleanup.exe (this fully removes corrupted setup and shared components)
      • Reinstall Visual Studio 2022 fresh
    3. As a temporary workaround
      • You may install Visual Studio 2026 Community side‑by‑side to unblock work, but this does not fix the underlying issue. A clean Visual Studio 2022 install is still recommended.

    This approach aligns with Microsoft’s guidance for build failures caused by missing internal runtime components and installer corruption.

    Please let us know if you require any further assistance, we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer". So that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


  2. Chris Guin 0 Reputation points
    2026-01-08T16:50:14.65+00:00

    Hey my coworker and I figured out what's going on. It has to do with the version of Newtonsoft Json dll in the GAC. Something updated the version to 13.0.4, which is causing lots of downstream failures with .NET and Visual Studio. I installed Newtonsoft.Json.dll version 13.0.3 and everything is now back to normal. Both versions are held in the same location in the GAC due to both being assembly version 13.0.0.0 which feels like the ultimate source of this problem.

    Thank you for trying to help me out and hopefully no one else runs into this issue.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.