为什么我不能将newtonsoft.Json.dll ref添加到我的项目中?

时间:2021-11-20 16:55:53

please view http://www.youtube.com/watch?v=6MRzbJBvM7c and jump to 1.25.

请查看http://www.youtube.com/watch?v=6MRzbJBvM7c并跳至1.25。

Im 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.

我试图添加一个参考'Newtonsoft.Json.dll'我已经按照他的要求。将此引用从“浏览”标签添加到“最近”标签。如果我查看ref列表中的refs列表,它会被列出但带有黄色标记。

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.

当我把光标放在旗帜上时,它说:不可用,因为它不存在,或者没有建成?所以我已经从ref列表中删除它并尝试重新添加它。

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

它只出现在'最近'部分,当我添加它时,我得到:

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

无法添加对“Newtonsoft.Json.dll”的引用。

Any ideas guys?

任何想法的家伙?

5 个解决方案

#1


29  

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.

它可能是你的构建系统中的东西:dll很可能被清理(如在重建中删除),或者在不在你的解决方案下的目录中,或者只是没有被复制到输出目录。

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.

对不起,我没有更具体的建议。我打算做的是建议你用射击枪杀死一只蚊子:使用NuGet。在使用Visual Studio(或任何其他.net IDE)的C#中,您确实想要使用nuget包管理器,因为它运行良好。

  1. Install the visual studio extension,
  2. 安装visual studio扩展,
  3. right click on your solution (dont do the project, do the solution)
  4. 右键单击您的解决方案(不要做项目,做解决方案)
  5. select 'Manage Nuget Packages for Solution'
  6. 选择'管理解决方案的Nuget包'
  7. click 'online', in the search box type 'newtonsoft'
  8. 点击'在线',在搜索框中输入'newtonsoft'
  9. click 'Install' on 'Json.NET' (probably, what your looking for might be in another package, I'll ask you to track it down).
  10. 点击“Json.NET”上的“安装”(可能,你在寻找可能在另一个包中的内容,我会要求你追踪它)。

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.

这将把它放在库目录中,将其包含在构建路径中,并允许您使用Intelli意义从项目中自动添加适当的引用。

#2


4  

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.

确保将项目目标框架设置为正确的版本。可能是您的项目目标.NET框架低于Newtonsoft dll的构建。右键单击您的项目,看看它的设置。你需要去查看属性。

#3


1  

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

好吧,这是一个愚蠢的答案,但有时你犯了愚蠢的错误......:如果你的解决方案中有几个子项目,请确保将引用添加到正确的(或全部)!

#4


1  

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

Nuget有效,但对于较旧的Visual Studios,例如2005/2008,它可能很棘手(不幸的是,这是我的情况)。

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!

我在这里下载了Json.NET。在二进制文件中,选择与.Net Framework版本匹配的文件,在项目的文件夹(例如lib)中添加dll,并将其作为参考包含在内。然后,玩得开心!

#5


0  

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

检查Json.net是否已安装在您的项目中。

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:

如果已安装,请从“packages.config”文件中删除“package”条目。现在转到NuGet“Package Manager Console”并使用以下命令安装新包:

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

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.

如果未安装,请转到NuGet并搜索JSon.Net并选择项目并单击安装。

Sreekanth

斯里卡特

#1


29  

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.

它可能是你的构建系统中的东西:dll很可能被清理(如在重建中删除),或者在不在你的解决方案下的目录中,或者只是没有被复制到输出目录。

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.

对不起,我没有更具体的建议。我打算做的是建议你用射击枪杀死一只蚊子:使用NuGet。在使用Visual Studio(或任何其他.net IDE)的C#中,您确实想要使用nuget包管理器,因为它运行良好。

  1. Install the visual studio extension,
  2. 安装visual studio扩展,
  3. right click on your solution (dont do the project, do the solution)
  4. 右键单击您的解决方案(不要做项目,做解决方案)
  5. select 'Manage Nuget Packages for Solution'
  6. 选择'管理解决方案的Nuget包'
  7. click 'online', in the search box type 'newtonsoft'
  8. 点击'在线',在搜索框中输入'newtonsoft'
  9. click 'Install' on 'Json.NET' (probably, what your looking for might be in another package, I'll ask you to track it down).
  10. 点击“Json.NET”上的“安装”(可能,你在寻找可能在另一个包中的内容,我会要求你追踪它)。

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.

这将把它放在库目录中,将其包含在构建路径中,并允许您使用Intelli意义从项目中自动添加适当的引用。

#2


4  

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.

确保将项目目标框架设置为正确的版本。可能是您的项目目标.NET框架低于Newtonsoft dll的构建。右键单击您的项目,看看它的设置。你需要去查看属性。

#3


1  

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

好吧,这是一个愚蠢的答案,但有时你犯了愚蠢的错误......:如果你的解决方案中有几个子项目,请确保将引用添加到正确的(或全部)!

#4


1  

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

Nuget有效,但对于较旧的Visual Studios,例如2005/2008,它可能很棘手(不幸的是,这是我的情况)。

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!

我在这里下载了Json.NET。在二进制文件中,选择与.Net Framework版本匹配的文件,在项目的文件夹(例如lib)中添加dll,并将其作为参考包含在内。然后,玩得开心!

#5


0  

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

检查Json.net是否已安装在您的项目中。

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:

如果已安装,请从“packages.config”文件中删除“package”条目。现在转到NuGet“Package Manager Console”并使用以下命令安装新包:

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

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.

如果未安装,请转到NuGet并搜索JSon.Net并选择项目并单击安装。

Sreekanth

斯里卡特