Hello,
I have an app domain with restriction. I want to use the JavaScriptSerializer in a partial trust assembly.
The behavior is really strange ! First thing was to add the System.Web.Extensions assembly in the PartialTrustVisibleAssemblies, this is normal.
The strange part comes after, when i try to serialize an object.
First attempt was with a string : SecurityException Request Failed (Need to be full trust assembly)
Second attempt was with a DateTime : No exception, correct serialization
Third attempt with a custom object (DataContract and a DataMember) : SecurityException Request Failed (Need to be full trust assembly)
The code for serialization is really simple :
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); serializer.Serialize("Hello World"); // SecurityException serializer.Serialize(DateTime.Now); // OK serializer.Serialize(myCustomObject); //SecurityException
Someone has an idea about this ?
EDIT : Using the DataContractJsonSerializer or the newtonsoft serializer, all works fine ! (not an answer for me, i would like even if the newtonsoft serializer is better, to use the javascriptserializer (easier to include in a sdk))