Fitzpleasure
Fitzpleasure

Reputation: 109

On start of asp.net mvc 4 application getting ambiguous exception- Index and length must refer to a location within the string. Parameter name: length

Here's the stack trace.

[ArgumentOutOfRangeException: Index and length must refer to a location within the     string.
Parameter name: length]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean  fAlwaysCopy) +10699039
System.Web.HttpApplication.HookupEventHandlersForApplicationAndModules(MethodInfo[] handlers) +312
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +107
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Index and length must refer to a location within the string.
Parameter name: length]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Is there any way to find out where this exception is coming from other than throwing random breakpoints everywhere? Thanks!

Upvotes: 0

Views: 249

Answers (1)

Dylan
Dylan

Reputation: 11

I ran into the same issue and was able to resolve it.

It turns out that at some point I fat-fingered something while in Global.asax.cs. I ended up changing the method Application_Error to Application_ (with a new line after it, stupid wide fingers...). This is what was causing the error to appear for me. Rewriting it as Application_Error resolved the issue.

Upvotes: 1

Related Questions