.NET Forum / Languages / C# / August 2006
System.NullReferenceException in XmlDocument.Load()
|
|
Thread rating:  |
docschnipp - 20 Aug 2006 10:38 GMT Hi,
I have a strange error that occurs on loading an XML document: The code is:
// create a document XmlDocument myDoc = new XmlDocument(); // and load it from file myDoc.Load(filename);
Inside of .Load()I am getting a System.NullReferenceException in about 1 out of 10 runs (always the same xml file).
If the exception occurs, the stack seems to be corrupt since I can not see the callstack but interesting enough a second thread (my app is single threaded) which seems the cause of the exception.
Is this a known bug or issue?
I am using .NET Framework 1.1 under Visual Studio 2003.
thanks doc
docschnipp - 20 Aug 2006 10:41 GMT I'd like to add some details:
Threadlist: 3592 <No Name> **MyApp**.DataDictionary Normal 0
>4028 <No Name> Highest 0 The crash occurs in the 4028 thread.
Anyone any idea?
Thanks doc
knowdotnet - 20 Aug 2006 11:47 GMT how do u specify the file name. i mean full path or relative path and is there any other file access in the same code.
> I'd like to add some details: > [quoted text clipped - 8 lines] > Thanks > doc docschnipp - 20 Aug 2006 14:01 GMT > how do u specify the file name. i mean full path or relative path and > is there any other file access in the same code. It is a string, name only, in the same directory. The app is not very complex. It is just always the same, but sometimes it just crashes.
The XML file itself is always the same.
But it crashes sometimes.
doc
Kevin Yu [MSFT] - 21 Aug 2006 09:13 GMT Hi,
I tried it on my machine, but I cannot reproduce it. If you simplify your code to just these 2 lines, does this also happens with the same xml file?
XmlDocument myDoc = new XmlDocument(); myDoc.Load(filename);
Kevin Yu Microsoft Online Community Support
================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ==================================================
(This posting is provided "AS IS", with no warranties, and confers no rights.)
docschnipp - 21 Aug 2006 10:23 GMT > Hi, > [quoted text clipped - 3 lines] > XmlDocument myDoc = new XmlDocument(); > myDoc.Load(filename); Yes, it is the same file all the time. The actual code that runs before is instantiation of some classes, which are totally simple, nothing unmanaged or so.
The crash does not happen all the time, but maybe it is connected to the fact I am running it in the debugger. It is only 1 out of 10 in average.
I wrote a set of classes to decode DICOM images and packed it into an Windows Forms application. I actually do run in an onClick() function of the form.
First I use a Fileselector to select the file to read, then the a new Class gets instanced. The first thing it does is reading an XML file which describes the Data Dictionary.
I can pass you the whole code, but I am pretty sure that there is no magic that could corrupt the memory or so before that runs.
The machine itself is totally stable.
Thanks so far,
doc
Kevin Yu [MSFT] - 22 Aug 2006 09:07 GMT Hi doc,
I understand this issue. I might not be very clear in my last post. We're trying to narrow down this issue. In my last post, I suggested you put into a smaller sample with only two lines of code.
XmlDocument myDoc = new XmlDocument(); myDoc.Load(@"c:\aaa.xml");
Please hardcode the file name and path to this sample. Run this sample in debugger as you ran you app to see whether the NullReferenceException is thrown again. Please try this and let me know the result. So I can provide my further steps to help.
Kevin Yu Microsoft Online Community Support ==================================================
(This posting is provided "AS IS", with no warranties, and confers no rights.)
Kevin Yu [MSFT] - 24 Aug 2006 10:43 GMT Hi doc,
I'd like to know if this issue has been resolved yet. Is there anything that I can help. I'm still monitoring on it. If you have any questions, please feel free to post them in the community.
Kevin Yu Microsoft Online Community Support ==================================================
(This posting is provided "AS IS", with no warranties, and confers no rights.)
docschnipp - 24 Aug 2006 10:50 GMT > Hi doc, > > I'd like to know if this issue has been resolved yet. Is there anything > that I can help. I'm still monitoring on it. If you have any questions, > please feel free to post them in the community. Hi Kevin,
not solved yet.
I didn't get the message that you responded, I will try that and let you know the result. I can also offer you to pass you the complete source and XML file.
best doc
Kevin Yu [MSFT] - 25 Aug 2006 06:46 GMT Hi doc,
In case of you didn't received my last post:
You can try to use a very simple project with only 2 lines of code.
XmlDocument myDoc = new XmlDocument(); myDoc.Load(@"c:\aaa.xml");
Run this project several times to see if the same exception is thown. Please let me know the results, and we can make further troubleshooting.
Kevin Yu Microsoft Online Community Support ==================================================
(This posting is provided "AS IS", with no warranties, and confers no rights.)
Kevin Yu [MSFT] - 29 Aug 2006 04:32 GMT Hi doc,
Have you reproduced this error with simplified code?
Kevin Yu Microsoft Online Community Support ==================================================
(This posting is provided "AS IS", with no warranties, and confers no rights.)
docschnipp - 29 Aug 2006 08:38 GMT Hi Kevin,
> Have you reproduced this error with simplified code? It did not come up with this variant, unfortunately I am currently bound to another project.
I am wondering if it is possible to still corrupt the memory heap in a managed app, because it only seems to happen when I am debugging, never had it when using the release version of it.
I will investigate a bit more when I am back on that project, for now I can not replicate it anymore, so we might close this for now, I will repost when I comes up again and I found something out.
Thanks for your help and support,
Doc
Kevin Yu [MSFT] - 30 Aug 2006 08:44 GMT No problem. When you come back to this issue, please repost in the commnity. Thank you!
Kevin Yu Microsoft Online Community Support ==================================================
(This posting is provided "AS IS", with no warranties, and confers no rights.)
DaanishRumani - 30 Aug 2006 09:46 GMT Is the file in the same folder as the EXE or that same folder as the Source File!!!!!!
> No problem. When you come back to this issue, please repost in the > commnity. Thank you! [quoted text clipped - 5 lines] > (This posting is provided "AS IS", with no warranties, and confers no > rights.)
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|