C# 错误:类型为';Newtonsoft.Json.Linq.JObject';存在于\Bin\Newtonsoft.Json.Net20.dll和\Bin\Newtonsoft.Json.dll中

C# 错误:类型为';Newtonsoft.Json.Linq.JObject';存在于\Bin\Newtonsoft.Json.Net20.dll和\Bin\Newtonsoft.Json.dll中,c#,asp.net,C#,Asp.net,/*如果我是在删除Newtonsoft.Json.dll之后构建的,那么它工作正常,但是在清理和构建之后会出现相同的错误吗*/ using System; using System.Web; using System.Data; using System.Collections; using localhost; using System.Text; using System.Collections.Generic; using System.Net.Mail; using System.Net

/*如果我是在删除Newtonsoft.Json.dll之后构建的,那么它工作正常,但是在清理和构建之后会出现相同的错误吗*/

using System;
using System.Web;
using System.Data;
using System.Collections;
using localhost;
using System.Text;
using System.Collections.Generic;
using System.Net.Mail;
using System.Net;
using BusinessLayerGDS.Model;
using BusinessLayerGDS.BAL;
using System.IO;
using System.Security.Cryptography;
using System.Linq;
using System.Configuration;
using Newtonsoft.Json.Linq;
using System.Text.RegularExpressions;
using System.Xml;



**And The codes:**
Newtonsoft.Json.Linq.JObject objActualData=Newtonsoft.Json.Linq.JObject.Parse(strResponse);

您需要做的是转到:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\临时ASP.NET文件

或此文件夹在计算机中的位置: > 临时ASP.NET文件

我看到一些人在下面配置它:

c:\Users[youruserid]\AppData\Local\Temp\Temporary ASP.NET文件

或者,您可能正在使用与v4.0.30319不同的.net版本

在该文件夹中,您可能会发现一些奇怪的文件夹名称,其中一个是应用程序的文件夹,您需要找到其中的文件夹,然后您应该删除bin中的文件夹

如果某些文件或文件夹被锁定,您可能需要停止IIS或IIS Express

返回并重建您的应用程序;它应该可以正常工作,然后关闭VS

用文本编辑器打开.csproj文件

查找Newtonsoft的所有hintpath标签

<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
。\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll

安装所有铰链-仔细查看,它可以在多个位置进行配置,Nuget对我来说也不是防弹的。

我也尝试过这一点。同一个dll的两个引用可能是不同的版本。我如何才能永久地从错误中恢复过来,因为我可以通过删除Newtonsoft.Json.dll文件,然后构建临时解决方案(它可以工作)。您必须检查csproj文件,并用旧版本删除
dll
。以我的经验,您不想这样做-它将继续查找,如果您在某处有另一个版本,它将使用该版本。使用文本编辑器修复.csproj文件-并确保HINTPATH外观良好,因为它可以定义多个位置。@user1515791这样做没有错。当然,除非您可以向我们展示其他方式,但在“我的经验”中,这就像一个charmWell,在我的例子中,问题是因为项目文件对程序集的引用无效-尽管使用了nuget和bindingredirects。所以我只使用它在文件系统上找到的第一个程序集。通过删除导致问题的1只是等待下一次(或更新、安装其他东西等),原因(对我来说)是无效的hintpath,修复它,问题就消失了,而不是症状。但是,我当然不知道这和你遇到的问题完全一样。