Jan*_*der 9 c# asp.net-mvc json.net asp.net-mvc-4
今天早上我醒来时发现我服务器上的MVC 4 Web应用程序坏了.
错误消息是:
An exception of type 'System.IO.FileNotFoundException' occurred in
mscorlib.dll but was not handled in user code.
Additional information: Could not load file or assembly
'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)
我打开我的VS项目并从代码运行它(所以在另一台计算机上),发生了同样的错误!
我检查了我的服务器日志,发现更新是在凌晨5:06自动安装的.其中一个更新是由安装程序包AspNetMVC4.msi完成的.一分钟后,我的Web应用程序上的第一个错误开始流入.
在我的开发笔记本电脑上,同样的安装程序昨天(10月15日)下午1:10:10运行.
两台计算机上的问题相同.
我从未听说过Newtonsoft.Json(但现在我发现它是什么).看起来好像其中一个MVC dll(不太可能)或其中一个包dll(更有可能)引用了Newtonsoft.
我试图从nuget安装Newtonsoft.这确实有一些影响,错误从FileNotFound更改为FileLoadException:
An exception of type 'System.IO.FileLoadException' occurred in
mscorlib.dll but was not handled in user code Additional
information: Could not load file or assembly 'Newtonsoft.Json,
Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
or one of its dependencies. The located assembly's manifest
definition does not match the assembly reference. (Exception
from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)
我还尝试从.NET 4.5升级到4.5.1.这没有用.
顺便说一句,错误发生在Global.asax.cs中的RegisterRoutes:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?