NET core - Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ', .NET 6

Viewed 9786

I have converted .NET Framework 3.5 TestAPP to .NET 6 TestAPP and worked well. i have an Automation project(C++ project) which was using .NET Framework 3.5 TestAPP.dll to run the tests, but right now i have replaced the .NET Framework 3.5 .dll with .NET 6 TestAPP i.e. TestAPP.dll when i ran the exe in command line , i have got an error as

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

Please let me know if anything needs to be corrected.

4 Answers

Resolved the error by changing the C++/CLI properties from visual studio project properties , which was referring to .NET framework earlier and i have changed the property as .NET core runtime(clr:netcore) and it is internally handled all GAC changes and worked well. Hope it might help someone . enter image description here

The running project returned this error. When I changed it to the way in the image, the error was solved.

Project>Properties

When upgrading an app to a later .NET version, edit your csproj file and make sure there is no <RuntimeFrameworkVersion> node in there that someone may have inserted manually. This will not be updated automatically when switching .NET versions

In my case the error was due to worng Default Project in Package Manager Console, if you are running EF migrations or something that is in a project that need to get info from the API make sure you are targetting the right project, also try clean + build first.

Related