Server Error in '/' Application.

Index and length must refer to a location within the string.
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: Index and length must refer to a location within the string.
Parameter name: length

Source Error:


Line 143:      
Line 144:        Do While offset < sb.Length
Line 145:            Dim pos As Integer = sb.ToString(offset - 5, 10).IndexOf("=0D=0A")
Line 146:            If pos = -1 Then
Line 147:                'Account for the string at the end of where we want to insert

Source File: G:\PleskVhosts\bentonlionsclub.org\httpdocs\Events_Download.ashx    Line: 145

Stack Trace:


[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
   System.Text.StringBuilder.ToString(Int32 startIndex, Int32 length) +13117544
   DownloadEvent.EncodeProperty(String key, String value) in G:\PleskVhosts\bentonlionsclub.org\httpdocs\Events_Download.ashx:145
   DownloadEvent.writeCalEntry(Int32 EventID, TextWriter output, String url) in G:\PleskVhosts\bentonlionsclub.org\httpdocs\Events_Download.ashx:117
   DownloadEvent.ProcessRequest(HttpContext context) in G:\PleskVhosts\bentonlionsclub.org\httpdocs\Events_Download.ashx:26
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +195
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +73


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0