Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

JavaScriptSerializer in a partial trust assembly

$
0
0

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))

Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>