We help IT Professionals succeed at work.

System.NullReferenceException being thrown and I don't know why - simple code

Krash_io asked
Last Modified: 2012-05-04
Hi experts, here's my code:

        Dim test As XmlDocument = New XmlDocument

        test.Load(System.AppDomain.CurrentDomain.BaseDirectory & "\support\configs\data\rsds\RRN_RSD.xml")


        test = Nothing

The line with the MsgBox is throwing a System.NullReferenceException and I can't figure out why.  Yes the XML document is in that path and well formed.  I can even read the first node of the xml document (which is the processing instruction), but when I try to read any deeper I get that error.  I cannont figure this out!  This code was running fine two days ago!

Please help!  Thanks!

Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)



I feel like such an idiot!  I tried selecting “//table” instead of “//Table” and it worked.  I don't think that I ever new that xPath syntax was case sensitive!  I guess I usually just used the same case to play it safe.  I must have changed the case in my xml document when I was adding to it, which is why the code used to run.  

I’ll award you the points, but only if you promise to not tell your friends about my noob mistake. :p


lol done deal! :)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.