I have a asp.net mvc 5 project in VS2013, I updated the nuget packages of everything to latest
then I run into this error
Error 2 The type 'Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver' exists in both 'c:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll' and '{path to my project}\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll'
Does anyone else run into this.
I got that error because I had an additional
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Owin">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
in my Web.csproj directly below the usual references which already contained the correct reference to the latest Newtonsoft.Json.dll. In VS only the reference to the newer assembly was shown.
Solution was: I moved the valid Owin reference to the main references ItemGroup and deleted the outdated Newtonsoft.Json.dll reference (manually editing the csproj file).
Cause of the error message: On my machine the HintPath of the old Newtonsoft.Json.dll did not exist, therefor MSBuild was looking elsewhere and took the Blend version.
(BTW: To see why and where MSBuild is looking for a certain assembly use TOOLS -> Options -> Projects and Solutions -> Build and Run -> und set the "MSBuild project build output verbosity" setting to "Detailed" and rebuild the project.)
I don't use Blend at all so I renamed the Blend Newtonsoft.Json.dll to "Newtonsoft.Json.dll.bak". This was mentioned as a work around in the Connect bug by Marcus. Marcus continues, saying that Blend may not use Newtonsoft.Json.dll much, so even if you use Blend it's possible that this fix will not affect your work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With