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;
}