在运行干净的解决方案并重新构建之后,我的MVC4Web API项目停止工作。它找不到Newtonsoft.Json。
我知道微软现在使用它作为默认的JSON序列化程序--但它不在项目的参考列表中,而且我不能从NuGet添加它,因为它说它已经安装了。
这里有没有人知道可能出了什么问题?
完整堆栈跟踪:
FileNotFoundException:未能加载文件或程序集“Newtonsoft.Json,Version=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。系统找不到指定的文件。
D:\ MvcWebRole1.WebApiApplication.Application_Error() \源代码控制的Projects\georace\georace\Server\GeoRaceServer\MvcWebRole1\Global.asax.cs:70中的数据
HttpException (0x80004005):未能加载文件或程序集'Newtonsoft.Json,Version=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed‘或其依赖项之一。系统找不到指定的文件。
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext环境,HttpApplication应用) +12838633
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext context,MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState状态、MethodInfo[]处理程序、IntPtr appContext、HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext context) +404
( System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
HttpException (0x80004005):未能加载文件或程序集'Newtonsoft.Json,Version=4.5.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed‘或其依赖项之一。系统找不到指定的文件。
System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文) +12851296 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文) +12679949
发布于 2012-08-19 23:35:37
好的-在我周围找到了一个工作,张贴以防其他人被这个MS bug鞭打。问题是你不能添加NuGet引用,因为默认情况下它已经包含在包中了。所以..。
发布于 2013-01-17 04:16:28
对于您想要重新安装的任何已由NuGet安装的包,只需在包管理器控制台中键入以下命令
在任何项目中更新:
Update-Package Newtonsoft.Json -Reinstall
在特定项目中更新
Update-Package Newtonsoft.Json -Reinstall -Project My.App
发布于 2014-02-07 04:35:05
对我来说,修复这个错误的惟一方法是将缺失的部分添加到我的web.config文件中,这是我从下面的答案中得到的:https://stackoverflow.com/a/20414714/940783
下面是我需要添加的内容:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
https://stackoverflow.com/questions/12027543
复制相似问题