Windows phone 7 WIndows Phone上的数据序列化

Windows phone 7 WIndows Phone上的数据序列化,windows-phone-7,twitter,datacontractserializer,Windows Phone 7,Twitter,Datacontractserializer,我正在关注TwitterAccess类(包含TwitterToken)被序列化的部分,我被卡住了。这是调用序列化方法的地方: void CallBackVerifiedResponse(OAuthAccessToken at, TwitterResponse response) { if (at != null) { SerializeHelper.SaveSetting<TwitterAccess>("Twit

我正在关注TwitterAccess类(包含TwitterToken)被序列化的部分,我被卡住了。这是调用序列化方法的地方:

    void CallBackVerifiedResponse(OAuthAccessToken at, TwitterResponse response)
    {
        if (at != null)
        {
            SerializeHelper.SaveSetting<TwitterAccess>("TwitterAccess", new TwitterAccess
            {
                AccessToken = at.Token,
                AccessTokenSecret = at.TokenSecret,
                ScreenName = at.ScreenName,
                UserId = at.UserId.ToString()
            });
        }
    }
void CallBackVerifiedResponse(OAuthAccessToken at,TwitterResponse)
{
如果(at!=null)
{
SerializeHelper.SaveSetting(“TwitterAccess”),新TwitterAccess
{
AccessToken=at.Token,
AccessTokenSecret=at.TokenSecret,
ScreenName=at.ScreenName,
UserId=at.UserId.ToString()
});
}
}
这是我的SerializeHelper.cs:

public class SerializeHelper
{
    public static void SaveSetting<T>(string fileName, T dataToSave)
    {
        using (var store = IsolatedStorageFile.GetUserStoreForApplication())
        {
            try
            {
                using (var stream = store.CreateFile(fileName))
                {
                    var serializer = new DataContractSerializer(typeof(T));
                    serializer.WriteObject(stream, dataToSave);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }
        }
    }

}
公共类序列化帮助器
{
公共静态void保存设置(字符串文件名,T dataToSave)
{
使用(var store=IsolatedStorageFile.GetUserStoreForApplication())
{
尝试
{
使用(var stream=store.CreateFile(文件名))
{
var serializer=新的DataContractSerializer(typeof(T));
serializer.WriteObject(流,dataToSave);
}
}
捕获(例外e)
{
MessageBox.Show(e.Message);
返回;
}
}
}
}

我遇到的错误是:
找不到类型或命名空间名称“DataContractSerializer”(是否缺少using指令或程序集引用?
Visual Studio无法帮助我解决此问题。它建议创建一个新类。我在谷歌上搜索了一下,我认为这个类应该在
System.Runtime.Serialization中但这并不能解决问题。

您必须添加项目中引用的
System.Runtime.Serialization.dll

您必须添加项目中引用的
System.Runtime.Serialization.dll

您的项目中是否有引用的
System.Runtime.Serialization.dll
使用System.Runtime.Serialization语句。或者我应该以其他方式将其添加到项目中选中“在Visual C#或Visual J#中添加引用”部分将其添加为引用修复了我的错误,谢谢!将此作为答案提交,我将接受。您的项目中是否引用了
System.Runtime.Serialization.dll
?我使用了
System.Runtime.Serialization语句。或者我应该以其他方式将其添加到项目中选中“在Visual C#或Visual J#中添加引用”部分将其添加为引用修复了我的错误,谢谢!把这个作为答案提交,我会接受的。