我随机获得2个异常,每次重新加载8-12页 - 其中一个例外也是随机的,它可能是第一个,也可能是第二个。例外情况如下
[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
-----和-----
[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
堆栈跟踪指向以下代码
using (var dataContext = new MyDataContext(Config.ConnectionString))
{
int numberOfBoardMessages = dataContext.BoardMessages.
Where(boardMessage => boardMessage.BoardMessageClasses.
Any(boardMessageClass => boardMessageClass.ClassId == currentClassId) && boardMessage.IsPublished).
Count();
}
我尝试过没有'BoardMessages'的空白数据库,但仍然出现错误。有没有人对可能出现的问题有任何想法?