I'm following this tutorial and I'm stuck at the part where the TwitterAcces class (that contains the twitter token) is serialized. This is where the serialization method is called:
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()
});
}
}
And this is my 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;
}
}
}
}
The error I'm getting is: The type or namespace name 'DataContractSerializer' could not be found (are you missing a using directive or an assembly reference?)
Visual Studio can't help me resolve the problem. It suggests creating a new class. I googled around and I think the class should be inside System.Runtime.Serialization;
which I am using but that doesn't solve the problem.
You got to add System.Runtime.Serialization.dll
referenced in your project.