Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

KB2656351 - JavaScriptSerializer - Deserialize Error: Operation is not valid due to the current state of the object.

$
0
0

After the security update KB2656351 http://support.microsoft.com/kb/2656351

We are running into an issue with JavaScriptSerializer while deserializing a json string which has more than 1000 members.

Even after adding required config entries in the app.config still facing the same issue.

Deserialization works fine with same string in the prior version (before the security update).

Change noticed: that System.Web.Extension.dll is upgraded to file version 4.0.30319.272 from 4.0.30319.1<o:p></o:p>

This is NOT  an ASP.NET application

.Net Platform : v4.0

Code:            

var jss = new System.Web.Script.Serialization.JavaScriptSerializer() { MaxJsonLength = int.MaxValue };var x = File.ReadAllText(@"c:\temp\Gibn_Reply__634928319272303850.json");

var y = jss.Deserialize<dynamic>(x); //Exception occured.

App.config [This not a web application]

<add key="aspnet:MaxHttpCollectionKeys" value"150000" /><add key="aspnet:MaxJsonDeserializerMembers" value"150000" />

Error :Operation is not valid due to the current state of the object.

Stack Trace:

System.Web.Extensions

System.Collections.Generic.IDictionary`2[System.String,System.Object] DeserializeDictionary(Int32)
System.Web.Extensions   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)
   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)
   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)
   at ConsoleApplication4.Program.Main(String[] args)

Suspected code causing issue in System.Web.Script.Serialization.JavaScriptObjectDeserializer

privatevoidThrowIfMaxJsonDeserializerMembersExceeded(int count)
{if (count>= AppSettings.MaxJsonDeserializerMembers)
    {thrownewInvalidOperationException();
    }
}

Please help




Viewing all articles
Browse latest Browse all 8156

Trending Articles



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