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

  • SEARCH
  • Home
  • 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 8589091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:57:47+00:00 2026-06-11T22:57:47+00:00

Related to ASP.NET MVC + LINQ exception I get 2 exceptions at a random

  • 0

Related to ASP.NET MVC + LINQ exception

I get 2 exceptions at a random of 8-12 page reloads – which of the exceptions is also random, it could be number one, it could be number two. The exceptions are the following

[IndexOutOfRangeException: Index was outside the bounds of the array.]
       System.Data.SqlClient.SqlDataReader.ReadColumnHeader(Int32 i) +701
       System.Data.SqlClient.SqlDataReader.IsDBNull(Int32 i) +29
       Read_BoardMessage(ObjectMaterializer`1 ) +348
       System.Data.Linq.SqlClient.ObjectReader`2.MoveNext() +42
       System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +472
       System.Linq.Enumerable.ToList(IEnumerable`1 source) +80
       Website.BusinessLogic.Services.BoardMessageService.GetBoardMessageModelsFromQuery(IQueryable`1 boardMessagesQuery) in D:\Applications\Website.BusinessLogic\Services\BoardMessageService.cs:167
       Website.BusinessLogic.Services.<>c__DisplayClass6.<GetStudentsBoardMessages>b__5() in D:\Applications\Website.BusinessLogic\Services\BoardMessageService.cs:89
       Library.Web.Utilities.RequestScopeCache.Get(String key, Func`1 defaultGetter) in D:\APPLICATIONS\Library\Web\Utilities\RequestScopeCache.cs:66
       Website.BusinessLogic.Services.BoardMessageService.GetStudentsBoardMessages(Int32 classId) in D:\Applications\Website.BusinessLogic\Services\BoardMessageService.cs:89
       Website.Web.usercontrols.ShowMessages.Initialize() in D:\Applications\Website.Web\usercontrols\ShowMessages.ascx.cs:28
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
       System.Web.UI.Control.LoadRecursive() +71
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064

—– and —–

[InvalidOperationException: Sequence contains more than one element]
   System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) +4539
   System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) +207
   System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +500
   System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute(Expression expression) +41
   System.Linq.Queryable.Count(IQueryable`1 source) +352
   Website.Web.usercontrols.TopMenu.SetStudentMenu() in D:\Applications\Website.Web\usercontrols\TopMenu.ascx.cs:93
   Website.Web.usercontrols.TopMenu.IsLoggedIn() in D:\Applications\Website.Web\usercontrols\TopMenu.ascx.cs:60
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.UI.Control.LoadRecursive() +71
  System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064

The stack trace points to the following code

using (var dataContext = new MyDataContext(Config.ConnectionString))
{
   int numberOfBoardMessages = dataContext.BoardMessages.
                Where(boardMessage => boardMessage.BoardMessageClasses.
      Any(boardMessageClass => boardMessageClass.ClassId == currentClassId) && boardMessage.IsPublished).
                    Count();
}

I have tried with a blank database with no ‘BoardMessages’ and the error still occurs. Does anyone have any ideas to what might be the problem?

  • 1 1 Answer
  • 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. Editorial Team
    Editorial Team
    2026-06-11T22:57:49+00:00Added an answer on June 11, 2026 at 10:57 pm

    Sounds like someone needs to use TransactionScope.

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

Sidebar

Related Questions

This question is related to my ASP.NET MVC 2 development, but it could apply
I have an ASP.NET MVC view and related model. How can I fill its
I'm trying to get started with the repository pattern and ASP.NET MVC, and I
I am trying to fix a design issue related to ASP.NET MVC 3 validation
I have an ASP.Net MVC page where I want to use AJAX to update
Here's a little background on my solution: ASP.Net MVC app Using Linq-to-SQL with table-per-hierarchy
My ASP.NET MVC project has some chapter class and related tag class They have
Related to this question I play around with XSS issues in my ASP.NET MVC
This is somewhat asp.net MVC related only for example purposes but I was hoping
I am getting Nhibernate Session closed exception with asp.net mvc telerik ajax grid. The

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.