-
August 9th, 2011, 02:33 AM
#1
Error in XML
Hi, I'm using .net 4.0
I'm trying to use serialization to save my array of monster and got this error:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll
Additional information: There was an error generating the XML document.
Here's my code:
public void Save()
{
using (IsolatedStorageFile saveGameFile = IsolatedStorageFile.GetUserStoreForApplication())
using (IsolatedStorageFileStream SaveGameStream = new IsolatedStorageFileStream("monster.dat", FileMode.OpenOrCreate, saveGameFile))
{
XmlSerializer serializer = new XmlSerializer(typeof(List<Monster>));
serializer.Serialize(SaveGameStream, _lMonster);
}
}
-
August 10th, 2011, 01:12 AM
#2
Re: Error in XML
Nothing looks obviously wrong upon code review (though obviously there is since it throw an exception...)
Which line throws the exception? I assume the call to serializer.Serialize(...)?
Failing that, is there a reason you are using XMLSerialization? Why not give binary serialization a try? It's slightly more challenging to implement, but offers some benefits.
Tutorial: http://www.codeproject.com/KB/cs/objserial.aspx
Sorry I can't be of more help!
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|