Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 629
John Avatar asked Aug 14 '13 11:08

John


4 Answers

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.

like image 73
Groostav Avatar answered Nov 08 '22 15:11

Groostav


Make sure that the your project target framework is set to the correct version. It might be that your target .NET framework for the project is lower than what the Newtonsoft dll was built under. Right click on your project and see what it's set at. You'll need to go view the properties.

like image 39
will Avatar answered Nov 08 '22 14:11

will


I had the same problem.

Nuget works, but for older Visual Studios, such as 2005/2008, it can be tricky (And that, unfortunately, was my case).

I downloaded Json.NET here. Inside binaries, choose the one that matches your .Net Framework version, add the dll inside a folder of your project (e.g. lib), and include it as a reference. Then, have fun!

like image 26
João Bruno Abou Hatem de Liz Avatar answered Nov 08 '22 14:11

João Bruno Abou Hatem de Liz


OK, this is a stupid answer, but sometimes you make stupid mistakes ...: if you have several sub-projects in your solution, make sure you add the reference to the right one (or to all) !

like image 35
werner Avatar answered Nov 08 '22 14:11

werner