C
Chris
I have an XMLdocument which I keep in cache which I use on my page. I use
this function (in a separate dll) to read it from the cache and then read it
from file if the cache is empty. This seems to work 99.9% of the time. But
every couple of days or so the app throws an 'Object reference not set to an
instance of an object.' on the getElementByTagName line below. Can anyone
help on what would cause this problem. And any recomendations how to best
troubleshoot it? Is it a file access issue? Am I using the cache wrong?
Regards.
xmlconfig = getcached_xml_doc(xmlpath, Me.xmlcachename)
nodelist = xmlconfig.GetElementsByTagName("nodes")
Public Function getcached_xml_doc(ByVal strxml As String, ByVal strcachename
As String) As XmlDocument
If HttpContext.Current.Cache(strcachename) Is Nothing Then
Dim xmldoc As New XmlDocument()
xmldoc.Load(HttpContext.Current.Server.MapPath(strxml))
HttpContext.Current.Cache.Insert(strcachename, xmldoc, New
CacheDependency(HttpContext.Current.Server.MapPath(strxml)))
'HttpContext.Current.Cache.Insert(strcachename, xmldoc)
End If
Return HttpContext.Current.Cache(strcachename)
End Function
this function (in a separate dll) to read it from the cache and then read it
from file if the cache is empty. This seems to work 99.9% of the time. But
every couple of days or so the app throws an 'Object reference not set to an
instance of an object.' on the getElementByTagName line below. Can anyone
help on what would cause this problem. And any recomendations how to best
troubleshoot it? Is it a file access issue? Am I using the cache wrong?
Regards.
xmlconfig = getcached_xml_doc(xmlpath, Me.xmlcachename)
nodelist = xmlconfig.GetElementsByTagName("nodes")
Public Function getcached_xml_doc(ByVal strxml As String, ByVal strcachename
As String) As XmlDocument
If HttpContext.Current.Cache(strcachename) Is Nothing Then
Dim xmldoc As New XmlDocument()
xmldoc.Load(HttpContext.Current.Server.MapPath(strxml))
HttpContext.Current.Cache.Insert(strcachename, xmldoc, New
CacheDependency(HttpContext.Current.Server.MapPath(strxml)))
'HttpContext.Current.Cache.Insert(strcachename, xmldoc)
End If
Return HttpContext.Current.Cache(strcachename)
End Function