未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30a
网站中用到了HttpClient和Newsoft.Json,在执行HttpClient.PostAsJsonAsync方法时抛出了异常:【未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)】。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.IO.FileLoadException: 未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
源错误:
行 150: PageSize = AspNetPager1.PageSize
行 151: };
行 152: var result = client.PostAsJsonAsync(url, filter).Result.Content.ReadAsStringAsync().Result;
行 153: var modelResult = JsonConvert.DeserializeAnonymousType(result, new
行 154: {
源文件: f:\work\usermanage\web\sellerhome\GoodsManager.aspx.cs 行: 152
程序集加载跟踪: 下列信息有助于确定程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”未能加载的原因。
=== 预绑定状态信息 ===
日志: DisplayName = Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
日志: Appbase = file:///F:/work/usermanage/web/
日志: 初始 PrivatePath = F:\work\usermanage\web\bin
调用程序集: System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35。
===
日志: 此绑定从 default 加载上下文开始。
日志: 正在使用应用程序配置文件: F:\work\usermanage\web\web.config
日志: 使用主机配置文件: C:\Users\Administrator\Documents\IISExpress\config\aspnet.config
日志: 使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的计算机配置文件。
日志: 策略后引用: Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/1992e148/1e3710e3/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/1992e148/1e3710e3/Newtonsoft.Json/Newtonsoft.Json.DLL。
日志: 尝试下载新的 URL file:///F:/work/usermanage/web/bin/Newtonsoft.Json.DLL。
警告: 比较程序集名称时发生不匹配: 主版本
错误: 未能完成程序集的安装(hr = 0x80131040)。探测终止。
堆栈跟踪:
[FileLoadException: 未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)]
System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() +0
System.Net.Http.HttpClientExtensions.PostAsJsonAsync(HttpClient client, String requestUri, T value, CancellationToken cancellationToken) +61
System.Net.Http.HttpClientExtensions.PostAsJsonAsync(HttpClient client, String requestUri, T value) +132
sellerhome_GoodsManager.loadData() in f:\work\usermanage\web\sellerhome\GoodsManager.aspx.cs:152
sellerhome_GoodsManager.Page_Load(Object sender, EventArgs e) in f:\work\usermanage\web\sellerhome\GoodsManager.aspx.cs:55
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772