I have an object and am trying to save it to the State dictionary, but when i pass an object to it using :
State["name"] = object;
i see some exceptions being raised:
A first chance exception of type
‘System.Runtime.Serialization.InvalidDataContractException’ occurred
in System.Runtime.Serialization.dll A first chance exception of type
‘System.Reflection.TargetInvocationException’ occurred in mscorlib.dll
A first chance exception of type
‘System.Runtime.Serialization.InvalidDataContractException’ occurred
in System.Runtime.Serialization.dll
State does automatically serialize and deserialize for objects passed. What could be the problem?
I suspect that the object must use [Serialize] when the class is declared. i try to use [Serialize] on my class but it isn’t recognized although i have using System.Runtime.Serialization; declared and the reference exists
UPDATE
here is the class that i’m trying to serialize :
public class MeshObject
{
public ModelMesh mesh; // xna specific class
public Matrix startOrientation; // xna specific class
public Matrix Orientation; // xna specific class
public bool isSetInPlace = false;
public bool isSelected = false;
public bool inPlay = false;
}
UPDATE 2
from what i understand from this post, there is no [Serializable] in Silverlight. How can i resolve this problem?
As you can read here
If you want to serialize a type that is not serializable you will need to implement the serialization yourself: http://mobile.dzone.com/articles/windows-phone-7-serialization