JSON.net 5.0 nuget package for silverlight is not recognized

1.2k Views Asked by At

Original question:

Is there something I need to change with the namespace, Newtonsoft.Json, or the packages.config files in order for Visual Studio 2010, Silverlight 5, NuGet, and JSON.Net to all play together properly?

After update:

Is there even a Json.Net assembly (or NuGet package) available for Silverlight 5?

I have a solution with several projects in the solution where the projects reference the JSON.net libraries. I am refactoring the Visual Studio solution to use NuGet instead of static, downloaded version (and then referencing the DLL file).

Right clicking on the projects and selecting "Manage NuGet Packages" works as expected and lets me install the Json.net" package to the .NET 3.5 projects within the solution and the Silverlight projects within the solution. All looked good at this point.

I set the setting to search for updates and to give NuGet permission to download missing packages.

The packages.config files found within the 3.5 and Silverlight 5 projects reference:

package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35"

and

package id="Newtonsoft.Json" version="5.0.8" targetFramework="sl50"

respectively.

No errors compiling the .Net 3.5 projects, but for the Silverlight 5 projects you get:

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
C:\CognexWorkSpace\TAF_Tools\src\TypeSafeEnumeration.Common\Enumeration.Serialization.cs

Is there something I need to change with the namespace, Newtonsoft.Json, or the packages.config files in order for Visual Studio 2010, Silverlight 5, NuGet, and JSON.Net to all play together properly?

FWIW: Visual Studio 2010 Intellisense flags the line:

using Newtonsoft.Json;

as unresolved, but again only in the Silverlight 5 projects.

Update

I should have been more clear on the solution structure. Currently, I have two projects (Json.Net35 and json.Silverlight) that are compiled from the Json.net 4 source code. The other projects within the solution then reference the particular variant of the JSON serializer needed for that project.

The refactoring of the solution was to upgrade the code base which led to implementing NuGet. With the NuGet approach temporarily block, I thought to reference the Json.net DLL's directly. When I downloaded the binaries though, the ZIP archive only contains these variants:

Net20
Net35
Net40
Net45
Portable
Portable40
WinRT

This question now morphs into:

Is there even a Json.Net assembly (or NuGet package) available for Silverlight 5?

If not that would easily explain the NuGet package question I began with and I am back to the original (current) approach, but with a newer version of source code.

1

There are 1 best solutions below

0
On

If you are using VS2010, the Portable projects are not supported, and you will need to go back to the 4.5 versions of Json.Net. I am not really sure that there is anything improved upon that Silverlight could even take advantage of, anyways, as the Portable projects typically exclude many of the updated features of Json.Net.

This is especially for Silverlight, as these need to be Portable40 projects, which exclude more than the Portable classes themselves.