Search code examples
c#jsonvisual-studio-2010referencejson.net

Why can't I add the newtonsoft.Json.dll ref to my project?


I am trying to add a reference 'Newtonsoft.Json.dll' I have followed what he has asked. which adds this ref from 'browse' tab to 'recent' tab. If I look at the list of refs from the ref list it is listed but with a yellow flag.

When I hold the cursor over the flag it says: not available as it does not exist, or is not built?? So I have removed it from the list of ref's and try to re-add it.

It only appears in the 'recent' section and when I add it, I get:

A reference to 'Newtonsoft.Json.dll' could not be added.


Solution

  • Its probably something in your build system: the dll is likely getting cleaned (as in deleted by a rebuild), or is in a directory that isn't under your solution, or simply isn't getting copied to the output directory.

    I'm sorry I don't have a more specific piece of advice. What I'm going to do though is suggest you use a shot-gun to kill a mosquito: use NuGet. In C# with Visual Studio (or any other .net IDE), you really want to use the nuget package manager, since it works so well.

    1. Install the visual studio extension,
    2. right click on your solution (dont do the project, do the solution)
    3. select 'Manage Nuget Packages for Solution'
    4. click 'online', in the search box type 'newtonsoft'
    5. click 'Install' on 'Json.NET' (probably, what your looking for might be in another package, I'll ask you to track it down).

    This will put it in a library directory, include it in the build path, and allow you to use the Intelli sense to auto-add the appropriate reference from your project.