Newtonsoft.Json version 8.0.2 Failed to load file or assembly Error

I am trying to parse a JSON file in a class library as part of a Web API solution. This is a regular C # class library, not a portable one.

I tried every answer mentioned here , but it still doesn't work! I keep getting the same error as:

Failed to load file or assembly "Newtonsoft.Json, Version = 8.0.0.0, Culture = neutral, PublicKeyToken = 30ad4fe6b2a6aeed" or one of its dependencies. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ":" Newtonsoft.Json, Version = 8.0.0.0, Culture = neutral, PublicKeyToken = 30ad4fe6b2a6aeed

Here is the code:

public IList<BranchRM> AllBranches()
{
    var result = new List<BranchRM>();
    var dataSourcePath = AppDomain.CurrentDomain.BaseDirectory + "Data/branches.json";
    var dataAsText = File.ReadAllText(dataSourcePath);
    if (string.IsNullOrEmpty(dataAsText)) return result;
    var branchList = JsonConvert.DeserializeObject<List<Branch>>(dataAsText);
    result = AutoMapper.Mapper.Map<List<BranchRM>>(branchList);
    return result;
}
+4
2

- Windows Phone 8 NuGet .

StivOstenberg .

, :

  • NuGet. "" NuGet. .
  • . .
  • using ! Newtonsoft.Json " ".
  • 2. ( )
  • NuGet (Ctrl + Shift + B).
  • , (), , .
  • 2 .

, , , . , .

+5

, Newtonsoft!

Newtonsoft.Json.8.0.3.

, StartUp - - MVC5. BundleTransformer.Less.X.X.X, Newtonsoft.Json.8.0.2. NewtonSoft.Json 8.0.3 ( ) .

0

Source: https://habr.com/ru/post/1624123/


All Articles