0

尝试反序列化我的数据时,出现以下异常:

{"Message":"使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串的长度超过 maxJsonLength 属性上设置的值。\r\n参数名称: 输入","StackTrace":" 在 System.Web.Script .Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer 序列化程序,字符串输入,类型类型,Int32 depthLimit)\r\n 在 System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](字符串输入)\r\n 在 System.Web .Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer 序列化程序)\r\n 在 System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n 在 System.Web.Script.Services .RestHandler.ExecuteWebServiceCall(HttpContext 上下文,WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}

这是代码:

Public Function Nominate(ByVal nominationRequest As String, ByVal nominee As String, ByVal coordinator As String) As Result
    Dim status As String = "ok"
    Dim messages As New List(Of String)

    Try
        Dim jsonSettings As JsonSerializerSettings = New JsonSerializerSettings()
        jsonSettings.NullValueHandling = NullValueHandling.Ignore
        jsonSettings.DefaultValueHandling = DefaultValueHandling.Ignore
        'jsonSettings.

        Dim jNomination As NominationRequest = JsonConvert.DeserializeObject(nominationRequest, GetType(NominationRequest), jsonSettings)
        Dim jNominee As Nominee = JsonConvert.DeserializeObject(nominee, GetType(Nominee), jsonSettings)
        Dim jCoord As Nominee = JsonConvert.DeserializeObject(coordinator, GetType(Nominee), jsonSettings)

        messages.AddRange(SaveNomination(jNomination, jNominee, jCoord))

    Catch ex As Exception
        status = "error"
        messages.Add(ex.ToString())
        ExceptionManagement.ExceptionManager.Publish(ex)
    End Try

    Dim result As Result = New Result()

    result.Status = status
    result.Messages = messages

    Return result
End Function

我只想让它与我作为参数得到的巨大字符串一起工作。我最初使用的是 4.5.14811 版本,并已更新到 5.08.16617 版本,希望它能解决我的问题(尽管变更日志没有给我太多希望)。我正在使用 .NET 3.5 版本的 DLL。如果您需要更多信息来帮助我解决这个问题,请告诉我。

谢谢

4

0 回答 0