尽管MaxJsonLength = Int32.MaxValue出现InvalidOperationException [英] InvalidOperationException despite MaxJsonLength = Int32.MaxValue

查看:332
本文介绍了尽管MaxJsonLength = Int32.MaxValue出现InvalidOperationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不认为我超过MaxJsonLength,但我仍然得到期间使用JSON JavaScriptSerializer序列化和反序列化时出错。字符串的长度超过上maxJsonLength属性设置的值。

I don't think I'm exceeding the MaxJsonLength, but I'm still getting "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property".

我检查,看看结果是怎么长的,它拥有25,000名行。我检查每一行的平均长度通过输出一个较小的结果,平均行是48.5个字符长。

I checked to see how long the result is, and it's 25,000 rows. I checked the average length of each row by outputting a smaller result, and the average row is 48.5 characters long.

25000 * 48.5字符= 1224140字。

25,000 * 48.5 characters = 1,224,140 characters.

MS说maxJsonLength是在字符的条款。 Int32.MaxValue超过2十亿。是什么给了?

MS says that maxJsonLength is in terms of characters. Int32.MaxValue is over 2 billion. What gives?

请注意:我不使用MVC,这是用VB编写的2010交谈jQuery的一个WebMethod。该结果是使用词典有组织的阵列。我得到的结果较小的集就好了。我证实,我的串行的maxJsonLength设置为最大值。

Note: I'm not using MVC, and this is a WebMethod written in VB 2010 talking to jQuery. The results are organized using a dictionary array. I get results for smaller sets just fine. I confirmed that my serializer's maxJsonLength was set to max.

提前感谢!

推荐答案

在ASP.NET有1000 JSON成员反序列化一个默认的最大值。据介绍,去年十二月。看看这是问题与您的应用程序。 这里有一篇文章这样。

In ASP.NET there is a default max value of 1000 JSON members for deserialization. It was introduced last December. See if this is the issue with your application. Here's an article for this.

这篇关于尽管MaxJsonLength = Int32.MaxValue出现InvalidOperationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆