After doing some thorough web browsing, I’ve seen two methods for serializing stuff in Windows Phone 7 to enter it into IsolatedStorage. I’m using VisualStudio 2010, with the November update for Silverlight, and this is a typical WP7 app, Panorama-based, not that this matters. They both need a couple of “using” clauses, then go through serialization and store the files.
In one of these methods, the one that seems easier and involve less meddling with the class I’m trying to serialize, I’m facing problems at the serialization part. XMLSerializer seems to not be there in the System.Xml.Serialization namespace. Is this something that used to be there and is no more? Here’s an example of page that seems to assume that XmlSerializer is there:
http://fatsweb.blogspot.com/2010/11/tombstoning-in-phone-7-xna-games.html
Note that this is a November post, so it’s fairly new. Is it that maybe it’s there for XNA apps and not for Silverlight apps? In any case, in my VS2010 XmlSerializer gives me the dreaded “type or namespace cannot be found” error and no options for resolving even after adding “using System.Xml.Serialization;” by hand. Any ideas where the heck this is?
One alternative answer seemed to be using the DataContractSerializer, but that would involve lots of meddling with my custom classes, entering all kinds of information for serialization in the class itself. I’d rather avoid that if possible.
In Silverlight (and therefore on the Phone too) this class is in a different assembly (not referenced by default).
You’ll need to add a reference to
System.Xml.Serialization.dllto be able to use it.However, be aware that XML serialization is slow. Strongly consider using something else.
A quick summary of the performance of the different options available:
– Binary is best for large data. Much faster than JSON and XML.
– JSON.NET is faster than the JSON serializer in the framework.
– XML is the slowest.