.netvisual-studiosharp-snmp

Failing to build sharpsnmplib samples in VS2019 could not load file or assembly System.Text.Json


I cloned the sharpsnmp lib samples and had been trying to build them with VS2019 but getting the following error:

Error NETSDK1060    Error reading assets file: Error loading lock file 'C:\src\c_sharp\sharpsnmplib-samples_v2\Samples.Engine\obj\project.assets.json' : Could not load file or assembly 'System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.   

For System.Text.Json I could find the specific version of the file on SDK packages (System.Text.Json, Version=7.0.0.3). I have got the different version of System.Text.json installed in the system (e.g. 6.0.3624.51421 e.g 8.0.1124.51707). One is higher than required version. But it was not picked during the build.

I tried to get the required packages updated manually by the NuGet package manager but it did not solve the issue. The updated package were not picked up.

Any clue on resolving the issue is greatly appreciated.


Solution

  • .NET 6 just reached end of life, so you need to use .NET 8 SDK and VS2022.