0
我在使用下面的代碼的同時獲得大約17 MB的PPTX文件的數組(如果任何文件小於15 MB,此工作正常)。在jss.Deserialize
線,它拋出錯誤「類型的異常‘System.OutOfMemoryException的’」JavaScriptSerializer反序列化拋出System.OutOfMemoryException
JavaScriptSerializer jss = new JavaScriptSerializer { MaxJsonLength = 2147483644, RecursionLimit = 100 };
var requestJson = jss.Serialize(new { serverRelativeUrl = serverRelativeUrl, token = token });
WebClient wClient = new WebClient();
wClient.Headers["Content-Type"] = "text/json; charset=utf-8";
var data = wClient.UploadData(serviceMethodURL, "POST", Encoding.UTF8.GetBytes(requestJson));
var responseJson = Encoding.UTF8.GetString(data);
var response = jss.Deserialize<MethodResponse<byte[]>>(responseJson);
任何想法?我堅持這一點。請幫助
如果使用JSON.NET序列化/反序列化,你可以用自定義的一個替代默認JsonValueProviderFactory如本博客文章:HTTP:// WWW .dalsoft.co.uk/blog/index.php/2012/01/10/asp-net-mvc-3-improved-jsonvalueproviderfactory-using-json-net/ – sagar43 2014-12-19 10:35:30
Thanx sagar,但它是一個Windows窗體應用程序,所以Global。 asax的東西是不可能的。 – Kaushal15 2014-12-19 10:59:37
@ Kaushal15但JSON.NET是... – t3chb0t 2014-12-19 12:07:41