XML cached document fails intermittantly

Discussion in 'ASP .Net' started by Chris, Mar 13, 2007.

  1. Chris

    Chris Guest

    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
    Chris, Mar 13, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig G
    Replies:
    0
    Views:
    388
    Craig G
    Mar 7, 2005
  2. darrel

    navigating a CACHED XML file...how?

    darrel, Mar 8, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    344
    darrel
    Mar 9, 2005
  3. Tony Prichard
    Replies:
    0
    Views:
    723
    Tony Prichard
    Dec 12, 2003
  4. Manish Hatwalne
    Replies:
    1
    Views:
    398
    Martin Honnen
    Jul 13, 2004
  5. wk
    Replies:
    5
    Views:
    166
    Dietmar Meier
    Apr 22, 2005
Loading...

Share This Page