Could not load file or assembly Newtonsoft.Json, Version= when running unit tests in parallel in VS2017


Using VS2017 MVC Web Api project, I have some unit tests which pass fine when run individually, but when run in parallel, I get the below error. I'd like to know how to be able to run these tests in parallel.

Message=Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

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

The code where the exception occurs is below at s.GetTypes():

using Newtonsoft.Json.Linq;

public static class Factory
    private static IEnumerable<MyAbstractClass> GetObjects(JObject parsedJson)
        var list = new List<MyAbstractClass>();
        var type = typeof(MyAbstractClass);
            .SelectMany(s => s.GetTypes())
            .Where(p => type.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract)
            .ForEach(t =>
                var item = (MyAbstractClass)Activator.CreateInstance(t);
                if (item.CanProcess(parsedJson)) list.Add(item);
        return list;

I have Newtonsoft.Json version referenced in the project ( so I'm not sure why it's wanting version

I have ensured that the web.config has:

    <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="" newVersion="" />

During the parallel run, one test (presumably the one that runs first), passes, and all others fail with the identical exception.

asked on Stack Overflow May 31, 2019 by Jayden

1 Answer


I've updated from Newtonsoft.Json version 11.0.1 to 11.0.2 and that appears to have fixed my issue.

answered on Stack Overflow Jun 7, 2019 by Jayden

User contributions licensed under CC BY-SA 3.0