Hi its me once again, i’ve encounter this xml error and i tried to undestand the problem and even solve but it didnt happen and im losing my brains xD I’ve never used XML with C# only JSON but im following the CodingMadeEasy tutorials(it could be done a remastered version for 2016).
I think the problem may be that you’re trying to deserialize a GameScreen class.
Maybe not all of the members of the GameScreen class are serializable.
Try to click on ‘View Detail…’ and look for the inner exception. That should tell you what the problem was.
IMO serialization won’t work on the GameScreen itself. You’d have to build a class that contains the data of the game, then save the data to that class and serialize it to disk.
Other way round, load it from disk, deserialize and put the data from your class back to the game itself.
Hmmm. Now, looking at the tutorial you were following… maybe you’ve forgotten the [XmlIgnore] annotation for the Type-field in the GameScreen class?
Your call to the XmlSerializer tries to generate a new class of type SplashScreen. So it has to have a public, parameterless constructor (as long as it has no constructor, it automatically has one).
Then it tries to populate all your public fields in that class. So those types should be serializable, even if your XML doesn’t contain values for them, since they’d get ‘null’ assigned.