昨天在开发时遇到一个很简单但是很奇怪的问题
if ((filterContext.HttpContext.Request.ContentType ?? string.Empty).Contains("application/json")) { object o =new DataContractJsonSerializer(RootType).ReadObject(filterContext.HttpContext.Request.InputStream); filterContext.ActionParameters[Param] = o; }
DataContractJsonSerializer 无法找到相应的链接库, 添加了System.Runtime.Serialization也无法解决。
解决问题的思路是:
1.认为是自己没有.net 3.0的版本,检查了之后发现存在,然后想到可能不是最新的版本,于是上网下载更新,结果依然没有解决问题。
2.google it and find the answer:
You need to add a reference to the System.ServiceModel assembly as well.
using System.Runtime.Serialization;
using System.ServiceModel;
System.Runtime.Serialization.dll(下载)
System.ServiceModel.dll
System.ServiceModel.Web.dll
Hope this helps!
Very Stranger but very happy