Recently, a project with URL rewriting went online and found that the error "the instance of the object is not referenced" sometimes occurs. After refreshing the page, the error disappears, but it will appear again later. the time of the intermediate interval is uncertain.
After one day of error capture, it is determined that this error occurs because of the loss of data cache. The data obtained through the cache is converted to null during use, resulting in errors.
I commented out the cache and there was no error.
But let's look at me.ProgramThe data was added to the cache before the cache was used, and then obtained immediately. What is the problem? I suspect there is a problem with the reference.
For testing, I set this part of cache access to system. Web. caching. cacheitempriority. notremovable. After that, no problem occurs.
Therefore, it should not be a reference error, but an inexplicable cache is cleared. However, after the cache is forcibly retained, no problem occurs.
The error is recorded here. Why? I will study it later. If you have any understanding, let's talk about it :)
// channelindexareas
If (cacheisinvaild (channelcachekey. channelindexareas)
{< br> cacheadddata (channelcachekey. channelindexareas, DT, channelcachekey. maxspan);
}< br> datatable dt = cachegetdata (channelcachekey. channelindexareas);
// channelindexmorelinks
If (cacheisinvaild (channelcachekey. channelindexmorelinks)
{< br> cacheadddata (channelcachekey. channelindexmorelinks, dtmore, channelcachekey. maxspan);
}< br> datatable dtmore = cachegetdata (channelcachekey. channelindexmorelinks);
// Channelindexsubtitles
If (cacheisinvaild (channelcachekey. channelindexsubtitles ))
{
Cacheadddata (channelcachekey. channelindexsubtitles, dtsubtitle, channelcachekey. maxspan );
}
Datatable dtsubtitle = cachegetdata (channelcachekey. channelindexsubtitles );
// Zikao _ area16 isn't null cache is null: the object reference is not set to the instance of the object
// The error is determined as cache loss, which may be caused by URL rewriting. The specific cause is unknown.
Try
{
Switch (item. itemtype)
{
Case edushop. Main. Business. appcontrol. channelitemtype. Area:
Fillarea (item, DT );
Break;
Case edushop. Main. Business. appcontrol. channelitemtype. Subtitle:
Filltitle (item, dtsubtitle, dtmore );
Break;
}
}
Catch (exception E)
{
Error = new error ();
String itemnull = (item = NULL? "Is null": "isn' t null ");
string cachenull = "cache isn't null";
If (Dt = NULL | dtsubtitle = NULL | dtmore = NULL)
cachenull = "cache is null";
error. logmessage = string. format ("{0} {1} {2 }:{ 3}", item. ID, itemnull, cachenull, E. message);
error. username = "channel page error Collector";
errornormal. insert (error);
}