C#Web API调用错误消息

时间:2015-12-08 20:32:42

标签: c# asp.net-web-api

我正在使用C#包装器HaloEzAPI

当我使用GetCustomPostGameCarnageReport拨打电话时,收到以下错误消息。

两天前它没有发生,只是突然开始。

它说错误发生在下面的第56行。 如果有人能帮助我,我将非常感激。

Number must be either non-negative and less than or equal to Int32.MaxValue or -1.
Parameter name: millisecondsTimeoutDescription: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Number must be either non-negative and less than or equal to Int32.MaxValue or -1.
Parameter name: millisecondsTimeout
Source Error:
Line 54: if (results.Id.MatchId != null)
Line 55: {
Line 56: var carnageReports = await _service.GetCustomPostGameCarnageReport(results.Id.MatchId);

我偶尔也会收到此错误

JSON integer 4294967295 is too large or small for an Int32. Path 'TeamStats[0].Score', line 1, position 2413.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Newtonsoft.Json.JsonReaderException: JSON integer 4294967295 is too large or small for an Int32. Path 'TeamStats[0].Score', line 1, position 2413.
Source Error:
Line 54: if (results.Id.MatchId != null)
Line 55: {
Line 56: var carnageReports = await _service.GetCustomPostGameCarnageReport(results.Id.MatchId);

1 个答案:

答案 0 :(得分:0)

根据您提供的错误:

  • 第二个错误说明非常清楚:json序列化尝试将序列化为整数的值太大了。实际上,在发生错误时TeamStats[0].Score中,您的值为4294967295,但.net中的max int值为2147483647。所以也许最好使用long而不是int(如果真的有这么大的值,则不要超出uint,以免超出其最大值);

  • 在我看来,第一个描述中的错误可能与int最大值的相同问题有关。如果可以发布更详细的堆栈跟踪超时问题,那么我们可以尝试深入了解并帮助您