Using a Newtonsoft.JSON DLL in multpiple projects01 Nov 2016 by Friedrich Ewald · 1 min read
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