John
John

Reputation: 3945

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.

Upvotes: 17

Views: 76801

Answers (6)

shiv roy
shiv roy

Reputation: 11

In my case i was face the same problem then i am able to resolve by flowing the article

http://microsoft-ssis.blogspot.com/2011/05/referencing-custom-assembly-inside.html

Add the assembly to GAC Before we can use our assembly, we have to add it to the global assembly cache (GAC). Open the Visual Studio 2008 Command Prompt again (for Vista/Windows7/etc. open it as Administrator). And execute the following command. gacutil /i d:\myMethodsForSSIS\myMethodsForSSIS\bin\Release\myMethodsForSSIS.dll

Upvotes: 0

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!

Upvotes: 2

user3778216
user3778216

Reputation: 21

Check to see if the Json.net is already install in your project.

If it is already installed go and remove the "package" entry from "packages.config" file. Now go to NuGet "Package Manager Console" and install the new package using the following command:

PM> Install-Package Newtonsoft.Json {Your Project Name} 6.0.3 nuget.org

If it is not installed, goto NuGet and search for JSon.Net and select the project and click install.

Sreekanth

Upvotes: 0

werner
werner

Reputation: 386

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) !

Upvotes: 1

Groostav
Groostav

Reputation: 3239

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.

Upvotes: 35

will
will

Reputation: 151

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.

Upvotes: 4

Related Questions