C# InternalSubStringWithChecks异常
我们在应用程序的healthMonitoring中得到这个InternalSubStringWithChecks异常 此异常类似于,无法删除正在记录的异常,我们收到一封通知电子邮件,但最终用户不知道实际发生了错误。虽然我们不想让我们的事件日志充满这些垃圾 堆栈跟踪是:C# InternalSubStringWithChecks异常,c#,asp.net,C#,Asp.net,我们在应用程序的healthMonitoring中得到这个InternalSubStringWithChecks异常 此异常类似于,无法删除正在记录的异常,我们收到一封通知电子邮件,但最终用户不知道实际发生了错误。虽然我们不想让我们的事件日志充满这些垃圾 堆栈跟踪是: Event message: System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length at Sy
Event message: System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
我找不到任何有用的信息是什么原因,以及如何通过谷歌修复它。是否有其他人遇到/修复了此问题 您正在使用不正确的参数调用Substring()方法。例如:
string a = "test";
a.Substring(0,100)
将引发异常 asp.net页面生命周期中什么时候会发生这种情况?@mohlsen-我们不知道,我们所得到的只是这个堆栈跟踪。查看提供的堆栈跟踪,他没有调用
Substring()
@Fedor,他调用了。您可以看到Substring()函数使用的InternalSubStringWithChecks。@是的,您是对的。我遇到了类似的问题,结果是,IIRC,ASP.NET在页面加载期间内部调用了Substring()
。不幸的是,我不记得是什么原因导致了这个错误,但我已经设法解决了它。