ArgumentOutOfRangeException: Length cannot be less than zero.

Jul 20, 2009 at 6:18 PM

I'd like to use this tool to aide in running web tests for InfoPath forms that are created using the XmlFormView control. I recorded the tests using the VS 2008 web test recorder and added the ExtractAndSubstituteDynamicInfoPathData plugin to each test (InvocationPath is set to the page under test). But when I run the test I get an ArgumentOutOfRangeException "Length cannot be less than zero" exception. I included the plug-in project in my solution and found that the exception is being thrown in the IPExtractionUtil.getg_ObjCurrentFormData(string body) method. It appears that the body param is empty which is causing the "body.Substring(...)" call to error.

Has anyone else run into this problem?

Coordinator
Jul 21, 2009 at 1:13 AM

Someone emailed me in April and they were getting a "Length cannot be less than zero" error when using the XmlFormView control.  In their case the request that was failing was a redirect.  Are you seeing a redirect?  My suggestion was to check e.Response.StatusCode in the PostRequest method of ExtractAndSubstituteDynamicInfoPathData.cs.

Coordinator
Jul 21, 2009 at 1:33 AM

I just checked in the fix I described.  Give that a try and let me know if works or not.

Jul 21, 2009 at 5:52 PM

My tests are still failing...but it appears to be for a different reason. So progress is being made :).

The tests themselves pass if I run them immediately after recording them. But fail after time passes so I'm assuming that somehow the new session details for each test isn't be replaced on the fly. Looking into it a little deeper, I found that the very first call to Postback.Formserver.aspx yields an g_objCurrentFormData array that includes the message "The current session is invalid" in it's body.

Any thoughts on what I might be doing wrong? For what it's worth, from debugging I can tell these are PartialPostBack calls.