将对象转换为HttpContent

时间:2018-04-18 06:47:11

标签: c# .net json.net httpresponse

将对象转换为HttpContent时,编译成功。但是在跑步的时候我遇到了错误。

  

无法加载文件或程序集'Newtonsoft.Json,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'或其中一个   的依赖关系。

我的代码段:

 JArray jarray = (JArray)response;  //response is of type var.    
 IEnumerable<MyModelClass> appResponse = jarray.ToObject<IEnumerable<MyModelClass>>();    
 HttpResponseMessage msg = new HttpResponseMessage();    
 msg.Content = new ObjectContent<IEnumerable<ConfigurationResponseDomainModel>>(appResponse, new JsonMediaTypeFormatter(), "application/json");

此行引发错误。将对象分配给内容。我使用的是Newtonsoft.Json(10.0.3)。任何帮助将不胜感激。

0 个答案:

没有答案