Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 72925

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:07:16+00:00 2026-05-10T20:07:16+00:00

I have an ASP.NET site that has been running perfectly for a long time,

  • 0

I have an ASP.NET site that has been running perfectly for a long time, nothing’s changed recently. From one hour to the next I started receiving an IndexOutOfRangeException in a line where I do a LINQ query like this:

var form = SqlDB.GetTable<ORMB.Form, CDB>()     .Where(f => f.FormID == formID)     .Single(); 

ORMB.Form is a POCO object with LINQ to SQL attributes mapping it to an MSSQL table (mapping is verified as correct). The stacktrace is as follows:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.    at System.Collections.Generic.List`1.Add(T item)    at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)    at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)    at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)    at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)    at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)    at System.Linq.Queryable.Single[TSource](IQueryable`1 source)    at GetForm.Page_Load(Object sender, EventArgs e) 

Reflecting System.Collections.Generic.List.Add shows the following code:

public void Add(T item) {     if (this._size == this._items.Length)     {         this.EnsureCapacity(this._size + 1);     }     this._items[this._size++] = item;     this._version++; } 

The only line that should be prone to the IndexOfOutRangeException is this._items[this._size++] = item, I cannot see how I’m affecting this however.

I can solve the problem by doing an appdomain recycle, so it must be caching related somehow. ObjectTracking is turned off on the DataContext, in case that matters.

My gut feeling is that this might be a threading issue, SqlConnectionManager having cached IConnectionUsers in the List field called ‘users’. If two threads enter the Add method at the same time, what prevents the following from happening:

T1: Add(x) T2: Add(y) T1: Since _size == _items.Length: EnsureCapacity(_size + 1) T2: Since _size > _items.Length: _items[_size++] = item; T1: _items[size++] = item <- OutOfRangeException since T2 didn't increase the capacity as needed 

Anyone?

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:07:16+00:00Added an answer on May 10, 2026 at 8:07 pm

    Are you sharing a common DataContext? That would explain the threading issues you are describing, as DataContext is not thread safe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Actually Firefox plugins (such as Flash, Java and video codec… May 11, 2026 at 3:39 pm
  • added an answer Statements cannot go inside of expressions in Python; it was… May 11, 2026 at 3:39 pm
  • added an answer Yes, you'd need to use Decimal.GetBits. Unfortunately, you then have… May 11, 2026 at 3:39 pm

Related Questions

Despite this being one of the best error messages I've ever seen (second only
I have a large-ish web project which is migrating from classic ASP to ASP.NET
This problem has been solved thanks to your suggestions. See the bottom for details.
I have had trouble getting web pages to load within Cassini for about a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.