XML cached document fails intermittantly

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top