Monday, October 17, 2005 10:17 AMI am getting this error "Length cannot be less than Zero".
After this error occured the application stops working and this same error messages gets displayed in all the pages.
If i replace the dll files again then the application starts working again.
I am pasting the complete error message below
Length cannot be less than zero. Parameter name: length
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: System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length] System.String.Substring(Int32 startIndex, Int32 length) +172 System.Web.UI.Util.GetScriptLocation(HttpContext context) +202 System.Web.UI.WebControls.BaseValidator.RegisterValidatorCommonScript() +69 System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +44 System.Web.UI.Control.PreRenderRecursiveInternal() +62 System.Web.UI.Control.PreRenderRecursiveInternal() +125 System.Web.UI.Control.PreRenderRecursiveInternal() +125 System.Web.UI.Page.ProcessRequestMain() +1499
please help me if someone know how to fix this error.
Monday, October 17, 2005 10:45 AMModeratorYou are using a negative length in any operation. Maybe a string operation were you request a part of the string and you defined length negative!
Just do what the messages says: Check the stack trace.
Launch the program in the debugger and see what happens. Usually you should see the wrong code line somewhere in the callstack.
Monday, October 17, 2005 1:20 PMThanks for your reply.
The error i was talking about is happening Inconstantly. It happens all of a sudden in a page and after that i am not able to access any page. But if i replace the application dll i am able to acces the application and the error does not occur if i do the same operation again which caused the errror perviously.
I am not doing any substring operation in my page. its usually in view pages i get this error. and the beauty is next time i will get this error in some other page.
Monday, October 17, 2005 2:24 PMModeratorI am afraid that it would be extremely difficult to speculate what is happening without having a small sample reproducing the issue.
You might want to try the newsgroups at http://msdn.microsoft.com/newsgroups/ for more feedback.
Tuesday, October 18, 2005 4:11 AMI am not able to find out where it error occurs. As the code works fine in development environment and when i host it i get this error.
After getting this error i will replace the dll. then the application will work again adn if i view the same page that caused the error it will work fine but i will get this error in some other page.
Is it some bug in ASP.NET
Tuesday, February 07, 2006 11:26 AMHi. Would be really interested in more feedback on this issue. We are experiencing exactly the same random error on our server - if we kill the .Net process it goes away, only to come back again a few days later. I am wondering if it's related to a automatic Windows update? We have clients being regularly affected by this on a regular basis. Can anyone suggest an approach?
Wednesday, March 01, 2006 12:55 AM
I am getting the same issue as well. It JUST started happening. It seems to only be happening if my .DLL is in Release mode. ??? If I switch out of Release and compile in debug mode and re-upload the dll to my host (atlantic.net) its works...
Wednesday, March 01, 2006 1:11 AMModerator
Do you have a sample to reproduce the issue?Thanks, Ayman Shoukry VC++ Team
Friday, April 07, 2006 8:02 AM
i got this error inconstantly in my appications page and itself it becoming ok...i belive i got this problem in a mean while i upgrade my dll in the web.....i think u too faced some problem like this
please let me know the solution.........
System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at System.Web.UI.Util.GetScriptLocation(HttpContext context)
at System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Tuesday, April 11, 2006 12:33 AM
I'm getting the same problem.. I'm not sure where it starts from either.
It occurs when I am Rendering attributes for a custom control. The only reference to Length is:
strAppName = strAppName.Substring(i + 4) + "/";
strCompleteAction = HttpContext.Current.Request.FilePath.Substring(strAppName.Length)+HttpContext.Current.Request.Url.Query;
Is this because of the way I am using APPL_MD_PATH? It only occurs on one deployment of many, so I think there may be something in IIS or elsewhere affecting this.
The most difficult part is, I cant replicate the error locally.
Any ideas would be appreciated!
Thursday, October 19, 2006 5:25 PMPlease help, i'm also experiencing the same problem. But very strange, it works fine if I load the same page using Firefox.. I can't find the answer anywhere..
Friday, March 13, 2009 10:49 AMI do think the problem is because of the substring function which you all are using.
The Substring function gets the upper lenght which exceeds the maximum length of the string value.
try this...........it might solve.
Thursday, June 11, 2009 9:32 PMI got that problem once because I was using like .IndexOf looking for something that didn't exist in the string. I looked and indexOf was returning a -1 for not found. maybe this helps?