如何在C#中执行System.Web.Script.Serialization? [英] How can I do System.Web.Script.Serialization in C#?

查看:681
本文介绍了如何在C#中执行System.Web.Script.Serialization?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#现代UI中做到这一点?

How can I do this in C# modern UI ?

var url = "http://ajax.googleapis.com/ajax/services/feed/load?q=http%3A%2F%2Fwww.digg.com%2Frss%2Findex.xml&v=1.0";
var wc = new WebClient();
var rawFeedData = wc.DownloadString(url);

//You can use System.Web.Script.Serialization if you don't want to use Json.NET
JavaScriptSerializer ser = new JavaScriptSerializer();
FeedApiResult foo = ser.Deserialize<FeedApiResult>(rawFeedData);

//Json.NET also return you the same strong typed object     
var apiResult = JsonConvert.DeserializeObject<FeedApiResult>(rawFeedData);

它给我错误WebClient和System.Web.Script.Serialization

It gives me error an error in WebClient and System.Web.Script.Serialization

推荐答案

我找到了使其工作的方法.
我不知道他们为什么会造成这种混乱,我什至都不知道为什么,但这是解决方案: 右键单击项目,然后添加对以下内容的引用:

I found how to make it work.
I don't know why they did this mess and I don't even understand why but here's the solution: Right click on project and add reference to:

System.Web.Extensions

System.Web.Extensions

您可以通过以下方式添加所需的参考:

than you can add the reference you need with:

using System.Web.Script.Serialization;

,这一次就可以了. (至少这是我在.NET Framework 3.5上所做的事情)

and this time it will work. (At least this is what I did on .NET framework 3.5)

这篇关于如何在C#中执行System.Web.Script.Serialization?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆