Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2013 and Newtonsoft.Json 3.5.0.2

Having installed VS2013 RC and previously the preview, MS seem to have created a situation where the integration of blend causes an old version of newtonsoft.json to end up high up in the search path during build. Causing this type of error

The type 'Newtonsoft.Json.Linq.JObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'Newtonsoft.Json, Version=3.5.0.2, Culture=neutral, PublicKeyToken=null'.

I've been renaming :

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll

which works, as does nuking these reg keys:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\Expression Blend MWD.Extensibility]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Blend\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\Expression Blend MWD.Interaction]
@="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Blend\\"

However there must be a better way? Surely dependencies not in the gac shouldn't be being found in the VS binary directories over our own target output ones?

like image 991
DanH Avatar asked Oct 21 '22 22:10

DanH


1 Answers

Use NuGet to install Newtonsoft.Json. This will cause something like the following to be added to your project file:

<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <Private>True</Private>
  <HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>

The HintPath will take precedence over the other search paths.

like image 91
Edward Brey Avatar answered Nov 11 '22 14:11

Edward Brey