In using SuspensionManager and the Session State on Windows 8, I tried saving an object into it and the app kept crashing on load.. Just spent four hours chasing my tail…
Finally figured it out. Here it is if anyone else is hitting it.
If you have a class pointing to object and that object is actually a class where the Namespace property on the DataContractAttribute is empty, you are going to fail deserialization.
The solution is simple (usually) – give that class a namespace..
Given class MyClass:
//[DataContract(Namespace = "http://dotnetfail")]
[DataContract(Namespace = "")]
public class MyData
The following code will throw on the last line. Notice how serialization works fine as long as you don’t actually point to MyClass from an object type (the first part)
The error points to a bogus location in the XML and gives a bogus exception description, sadly (which is why it took me so long to find it).
The following exception is thrown:
Error in line 1 position 202. 'EndElement' 'KeyValueOfstringanyType' from
namespace 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not
expected. Expecting element 'Value'.