This is the second time this error has come up within the last week and I can't see any cause for it. The null reference is deeper inside the DataTable than I'm touching, so I don't know what goes wrong. First a little information:
being called from
The most I can get down to is that it's something that screws up in the datatable object itself. When the error happens, it gets cached and comes up for everyone with the same Session("portal") value. The query is always the same for a given "portal" and it works the vast majority of the time. The first time the error happened, I was in the office and cleared the cache by touching web.config and the error went away.
This second time it happened over the weekend and it looks like it only affected two people for two minutes (the problem was either fixed or the two users gave up). The first error this weekend happened to both users during the same second.
The DataTable is retrieved from the database using a custom class that's been in production for over a year, so I really doubt it's at fault. GetCategories is a shared method of a class that is called from a variety of places, and a similar error comes up when those pages are hit.
Googling for different methods/objects in the call stack didn't come up with anything related. Can someone offer a pointer of where else I should look? Is there any more information I can offer that would help?
.NET Framework 1.1 SP1 + hotfix
Thanks for your time.
________________________________________
Andrew
Code:
* System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Index.InitRecords()
at System.Data.Index..ctor(DataTable table, Int32[] indexDesc, DataViewRowState recordStates, IFilter rowFilter)
at System.Data.Select.CreateIndex()
at System.Data.Select.SelectRows()
at System.Data.DataTable.Select(String filterExpression, String sort)
at ProductList.Page_Load(Object sender, EventArgs e) in C:\VSASP\vipweb\Products\ProductList.ascx.vb:line 63
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
Code:
...
Dim dt As DataTable = GetCategories
Dim dr As DataRow = dt.NewRow
dr("CategoryID") = 0
dr("Description") = "All"
dr("Parent") = iCat
dt.Rows.InsertAt(dr, 0)
'next line is 63
Filter.DataSource = dt.Select("[Parent] = " & iCat, "Description")
Filter.DataBind()
...
Public Shared Function GetCategories() As DataTable
Dim key As String = "Cats" & Utils.clean(HttpContext.Current.Session("portal"))
If HttpContext.Current.Cache(key) Is Nothing Then
dim dt as DataTable
''' fill dt from database '''
HttpContext.Current.Cache.Insert(key, dt, Nothing, Now.AddHours(6), TimeSpan.Zero)
End If
Return CType(HttpContext.Current.Cache(key), DataTable)
End Function
This second time it happened over the weekend and it looks like it only affected two people for two minutes (the problem was either fixed or the two users gave up). The first error this weekend happened to both users during the same second.
The DataTable is retrieved from the database using a custom class that's been in production for over a year, so I really doubt it's at fault. GetCategories is a shared method of a class that is called from a variety of places, and a similar error comes up when those pages are hit.
Googling for different methods/objects in the call stack didn't come up with anything related. Can someone offer a pointer of where else I should look? Is there any more information I can offer that would help?
.NET Framework 1.1 SP1 + hotfix
Thanks for your time.
________________________________________
Andrew