Friedrich Ewald My Personal Website

Using a Newtonsoft.JSON DLL in multpiple projects

When building a Visual Studio solution, I had the problem that I got a TargetInvocationException when calling a method from a referenced DLL file. When running the unit tests on the DLL file, everything seemed to work fine and I could not track down the problem. The inner exception of the exception brought me then on the right track: The Newtonsoft.JSON module was installed in different versions across each DLL file and the main project.

' Write the exception to the console.
Try
        response = Await client.Login("a", "b")
    Catch ex As Exception
        Console.WriteLine(ex.InnerException)
    End Try
The solution is simple. I just had to make sure, that the DLL is used in the same version in every project. This can simply be done with the console of the package manager.
PM> Update-Package Newtonsoft.JSON -reinstall
PM> Update-Package Newtonsoft.JSON


About the author

is an experienced Software Engineer with a Master's degree in Computer Science. He started this website in late 2015, mostly as a digital business card. He is interested in Go, Python, Ruby, SQL- and NoSQL-databases, machine learning and AI and is experienced in building scalable, distributed systems and micro-services at multiple larger and smaller companies.