473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

System.NullReferenceException in XmlDocument.Load()

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

Aug 20 '06 #1
13 4829
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

Aug 20 '06 #2
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.

docschnipp wrote:
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
Aug 20 '06 #3
"knowdotnet" wrote:
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

Aug 20 '06 #4
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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Aug 21 '06 #5
"Kevin Yu [MSFT]" wrote:
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);
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

Aug 21 '06 #6
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.)

Aug 22 '06 #7
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.)

Aug 24 '06 #8
"Kevin Yu [MSFT]" wrote:
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

Aug 24 '06 #9
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.)

Aug 25 '06 #10
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.)

Aug 29 '06 #11
Hi Kevin,

"Kevin Yu [MSFT]" wrote:
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

Aug 29 '06 #12
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.)

Aug 30 '06 #13
Is the file in the same folder as the EXE or that same folder as the
Source File!!!!!!

Kevin Yu [MSFT] wrote:
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.)
Aug 30 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
7
by: Microsoft News | last post by:
Hi all. Does id() xpath function work in System.XML? I have built dtd, schema, xdr for a simple xml which includes attributes definded as ID and IDREFS. Validation is occurring properly for all...
1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
2
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) {...
4
by: John Smith | last post by:
How can I allow someone to cast my C# class into System.String? Is it possible in C#? In C++ I used "operator" keyword to mark C++ member function.
2
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When...
0
by: Siberwulf | last post by:
I'm trying to fetch an XML document from a website through an assembly i built and attached to SQL 2005. Here is my code for the SPROC assembly: public static void fetch_FeedData(string...
1
by: kowshikj | last post by:
In a ASP.NET 1.1 application, we get this exception at xmlDoc.Load() when loading an XmlDocument. This does not seem to happen every time though. The xml file itself is only 10 KB and we don't use...
2
by: rhepsi | last post by:
hii all, im a fresher, and new to the programming side.. when im trying to execute a project... m getting an exception at the line : If MyDocument.length=0 the code goes on like this: ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.