Microsoft .NET Team:
I would like to report what I think is a bug in the
XMLTextReader class. The bug can be reproduced in the
following manner:
1) Create a C# Windows Application Project and add a form
to it. Add System.XML to the namespaces of the project.
2) Add a ListBox control to the form, name it lbUsers
3) Add the following code to the OnLoad event of the form:
protected override void OnLoad(EventArgs e)
{
XmlTextReader xmlConfigFile;
string filename = Application.StartupPath
+ "\\test.vtx";
xmlConfigFile = new XmlTextReader(filename);
while(xmlConfigFile.Read())
{
if(xmlConfigFile.NodeType == XmlNodeType.Element)
{
if(xmlConfigFile.Name == "User")
{
if(xmlConfigFile.HasAttributes)
{
while(xmlConfigFile.MoveToNextAttribute())
{
if(xmlConfigFile.Name == "Name")
lbUsers.Items.Add
(xmlConfigFile.Value);
}
}
}
}
}
lbUsers.Refresh();
base.OnLoad (e);
}
4) Place the following XML File in the application
directory for the project (the /debug directory). Name
the file test.vtx
<?xml version="1.0" encoding="UTF-8" ?>
<ConfigData>
<UserInfo>
<Users>
<User Name="AUDREY">
</User>
<User Name="WESLEY">
</User>
<User Name="DADDY">
</User>
</Users>
</UserInfo>
</ConfigData>
5) DO NOT PLACE any breakpoints in the code.
6) Use the F5 key (Debug/Run) to execute the code.
Result: The machine will hang. The only choice is the
power switch. CTRL-ALT-DEL is ineffective.
Other information:
a) If you execute this code from a Button.Click event on
the form, IT WORKS JUST FINE.
b) If you comment out all of the code inside the while
loop in the function, the machine will still hang.
c) If you move the base class OnLoad above the while
loop, the code will still hang.
d) If you put this code in the OnActivate function of the
form, the code will still hang.
Please verify this bug, and suggest a workaround if
possible. Thank you for your help.
Walt Smith
Vectiva.com
|