XmlTextReader ReadChars can enter an infinate loop when reading st

The following code will enter an infinate loop when in ReadChars.  I can only 
make it happen when reading a Stream and with this particular XML.  If I use 
the ReadInnerXml call rather than my own ReadElementBodyAsXml the code works, 
but is less efficent.  ReadElementBodyAsXml is required by my application 
with .Net Framework 1.1.

The code breaks on the second call to ReadElementBodyAsXml with the inner xml:
</EGDConfigExtension>
	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
ExtensionCode="MasterHmiResources"><HmiResources>
	<HmiResource Name="hgyugyg" />
</HmiResources></EGDConfigExtension>


This is bad behavior, so I felt it should be posted.  Maybe it is already 
know to be fixed in SP1 (hopefully forthcoming).

Regards,
Rick

--- code that breaks ---
		private void ReadXml()
		{
			FileStream fs = File.OpenRead(@"MasterSymbolTable.xml");
			XmlTextReader reader = new XmlTextReader(fs, XmlNodeType.Element, null);
			reader.MoveToContent();
			reader.ReadToDescendant("EGDConfigExtension");
			string xml = ReadElementBodyAsXml(reader);
			reader.Read();
			xml = ReadElementBodyAsXml(reader);
		}

		private string ReadElementBodyAsXml(XmlTextReader reader)
		{
			int startingLineNumber = reader.LineNumber;
			int startingLinePosition = reader.LinePosition;
			int startingDepth = reader.Depth;
			bool startingElementIsEmpty = reader.IsEmptyElement;
			string startingName = reader.Name;

			System.Diagnostics.Debug.Assert(reader.NodeType == XmlNodeType.Element, 
"Node type must be Element.",
				"ReadElementBodyAsXml should be called when the reader is positioned on 
an element.  It will simply return null if it is not, but the intention is 
for it to be used to read element content.");

			char[] buffer = new char[512];
			int totalRead = 0;
			int i;
			while ((i = reader.ReadChars(buffer, totalRead, buffer.Length - 
totalRead)) > 0)
			{
				totalRead += i;
				if (reader.Depth <= startingDepth)
				{
					// Even though we read chars, the LineNumber and LinePosition do not 
change
					// unless we read a node.  We don't want to read any more unless we are
					// on a child node.  But we also need to make sure that we are not still
					// on the same node that we started with, since we could have some very
					// big nodes.  It is hard to tell if ReadChars returned because it did
					// not have any more content buffered or if it got to the end of a node.
					// If at the end of a node, which node?
					// This code fixes SCR 2923.
					if (reader.NodeType != XmlNodeType.Element)
						break; // We must not be on the node we started on.
				}
				if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 
startingDepth)
					break;
				if (totalRead == buffer.Length)
				{
					char[] newBuf = new char[buffer.Length + 512];
					Buffer.BlockCopy(buffer, 0, newBuf, 0, totalRead * 2); // Each char is 
2 bytes.
					buffer = newBuf;
				}
			}

			string innerXml = null;
			if (totalRead > 0)
				innerXml = new string(buffer, 0, totalRead);
			else
				innerXml = null;

			return innerXml;
		}



-----  XML file MasterSymbolTable.Xml  ---
<?xml version="1.0" encoding="utf-8"?>
<?GeCssClass type="GeIndsysNetworkCoe.EgdConfig.EgdMasterSymbolTable, 
EgdCoeConfig"?>
<MasterEgdSymbolTable EGDSpecVersion="3.04" ConfigTimeSecs="1160762827" 
ConfigTimeNSecs="704238500" xmlns="http://geindustrial.com/EGD" Name="Demo">
	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
ExtensionCode="MasterAlarms"><AlarmClasses>
	<AlarmClass Name="Alarm" Description="Default Class for Process Alarms" 
DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
NormalSeverity="350" ActiveSeverity="500" />
	<AlarmClass Name="Trip" Description="Default Class for Convertor Trips" 
DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
AckBackgroundColor="White" AckForegroundColor="Maroon" IsIntrinsic="true" 
NormalSeverity="350" ActiveSeverity="500" />
	<AlarmClass Name="System" Description="Default Class for WorkstationST 
System alarms" DescAlt="" NormalBackgroundColor="White" 
NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
AlarmForegroundColor="White" AckBackgroundColor="White" 
AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
ActiveSeverity="500" />
	<AlarmClass Name="Diagnostic" Description="Default Class for Process 
Diagnostics" DescAlt="" NormalBackgroundColor="White" 
NormalForegroundColor="Black" AlarmBackgroundColor="Red" 
AlarmForegroundColor="White" AckBackgroundColor="White" 
AckForegroundColor="Red" IsIntrinsic="true" NormalSeverity="350" 
ActiveSeverity="500" />
	<AlarmClass Name="Hold" Description="Default Class for Holds" DescAlt="" 
NormalBackgroundColor="White" NormalForegroundColor="Black" 
AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
NormalSeverity="350" ActiveSeverity="500" />
	<AlarmClass Name="Diag" Description="Default Class for Process Diagnostics" 
DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
NormalSeverity="350" ActiveSeverity="500" />
	<AlarmClass Name="Sys" Description="Default Class for WorkstationST System 
alarms" DescAlt="" NormalBackgroundColor="White" 
NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
AlarmForegroundColor="White" AckBackgroundColor="White" 
AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
ActiveSeverity="500" />
	<AlarmClass Name="TEST" Description="Test Alarm Class" DescAlt="" 
NormalBackgroundColor="White" NormalForegroundColor="Black" 
AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
AckBackgroundColor="White" AckForegroundColor="Maroon" NormalSeverity="350" 
ActiveSeverity="500" />
	<AlarmClass Name="OpSet" Description="Alarm Class for Operator Setpoint 
Events" DescAlt="" NormalBackgroundColor="White" 
NormalForegroundColor="Black" AlarmBackgroundColor="Yellow" 
AlarmForegroundColor="Black" AckBackgroundColor="Black" 
AckForegroundColor="Yellow" IsIntrinsic="true" NormalSeverity="350" 
ActiveSeverity="500" />
	<AlarmClass Name="SOE" Description="Default Class for Sequence of event" 
DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
NormalSeverity="350" ActiveSeverity="500" />
	<AlarmClass Name="Event" Description="Default Class for Process Events" 
DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
NormalSeverity="350" ActiveSeverity="500" />
</AlarmClasses></EGDConfigExtension>
	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
ExtensionCode="MasterHmiResources"><HmiResources>
	<HmiResource Name="hgyugyg" />
</HmiResources></EGDConfigExtension>
	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
ExtensionCode="MasterPlantAreas"><PlantAreas>
	<PlantAreaPath Path="Plant" />
	<PlantAreaPath Path="Plant.PlantArea01" />
	<PlantAreaPath Path="Plant.PlantArea01.PlantArea21" />
	<PlantAreaPath Path="Plant.PlantArea02" />
	<PlantAreaPath Path="Plant.PlantArea04" />
	<PlantAreaPath Path="Plant.PlantArea14" />
	<PlantAreaPath Path="Plant.PlantArea15" />
</PlantAreas></EGDConfigExtension>
</MasterEgdSymbolTable>

0
rickshaw (7)
10/26/2006 8:49:02 PM
dotnet.xml 7266 articles. 0 followers. Follow

13 Replies
683 Views

Similar Articles

[PageSpeed] 38

I forgot to mention, the infinate loop is in .Net Framework 2.0.  I have the 
hotfixes (KB924895 and KB922271) (as well as 2 security updates) installed.
-- 
Rick


"Rick" wrote:

> The following code will enter an infinate loop when in ReadChars.  I can only 
> make it happen when reading a Stream and with this particular XML.  If I use 
> the ReadInnerXml call rather than my own ReadElementBodyAsXml the code works, 
> but is less efficent.  ReadElementBodyAsXml is required by my application 
> with .Net Framework 1.1.
> 
> The code breaks on the second call to ReadElementBodyAsXml with the inner xml:
> </EGDConfigExtension>
> 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> ExtensionCode="MasterHmiResources"><HmiResources>
> 	<HmiResource Name="hgyugyg" />
> </HmiResources></EGDConfigExtension>
> 
> 
> This is bad behavior, so I felt it should be posted.  Maybe it is already 
> know to be fixed in SP1 (hopefully forthcoming).
> 
> Regards,
> Rick
> 
> --- code that breaks ---
> 		private void ReadXml()
> 		{
> 			FileStream fs = File.OpenRead(@"MasterSymbolTable.xml");
> 			XmlTextReader reader = new XmlTextReader(fs, XmlNodeType.Element, null);
> 			reader.MoveToContent();
> 			reader.ReadToDescendant("EGDConfigExtension");
> 			string xml = ReadElementBodyAsXml(reader);
> 			reader.Read();
> 			xml = ReadElementBodyAsXml(reader);
> 		}
> 
> 		private string ReadElementBodyAsXml(XmlTextReader reader)
> 		{
> 			int startingLineNumber = reader.LineNumber;
> 			int startingLinePosition = reader.LinePosition;
> 			int startingDepth = reader.Depth;
> 			bool startingElementIsEmpty = reader.IsEmptyElement;
> 			string startingName = reader.Name;
> 
> 			System.Diagnostics.Debug.Assert(reader.NodeType == XmlNodeType.Element, 
> "Node type must be Element.",
> 				"ReadElementBodyAsXml should be called when the reader is positioned on 
> an element.  It will simply return null if it is not, but the intention is 
> for it to be used to read element content.");
> 
> 			char[] buffer = new char[512];
> 			int totalRead = 0;
> 			int i;
> 			while ((i = reader.ReadChars(buffer, totalRead, buffer.Length - 
> totalRead)) > 0)
> 			{
> 				totalRead += i;
> 				if (reader.Depth <= startingDepth)
> 				{
> 					// Even though we read chars, the LineNumber and LinePosition do not 
> change
> 					// unless we read a node.  We don't want to read any more unless we are
> 					// on a child node.  But we also need to make sure that we are not still
> 					// on the same node that we started with, since we could have some very
> 					// big nodes.  It is hard to tell if ReadChars returned because it did
> 					// not have any more content buffered or if it got to the end of a node.
> 					// If at the end of a node, which node?
> 					// This code fixes SCR 2923.
> 					if (reader.NodeType != XmlNodeType.Element)
> 						break; // We must not be on the node we started on.
> 				}
> 				if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 
> startingDepth)
> 					break;
> 				if (totalRead == buffer.Length)
> 				{
> 					char[] newBuf = new char[buffer.Length + 512];
> 					Buffer.BlockCopy(buffer, 0, newBuf, 0, totalRead * 2); // Each char is 
> 2 bytes.
> 					buffer = newBuf;
> 				}
> 			}
> 
> 			string innerXml = null;
> 			if (totalRead > 0)
> 				innerXml = new string(buffer, 0, totalRead);
> 			else
> 				innerXml = null;
> 
> 			return innerXml;
> 		}
> 
> 
> 
> -----  XML file MasterSymbolTable.Xml  ---
> <?xml version="1.0" encoding="utf-8"?>
> <?GeCssClass type="GeIndsysNetworkCoe.EgdConfig.EgdMasterSymbolTable, 
> EgdCoeConfig"?>
> <MasterEgdSymbolTable EGDSpecVersion="3.04" ConfigTimeSecs="1160762827" 
> ConfigTimeNSecs="704238500" xmlns="http://geindustrial.com/EGD" Name="Demo">
> 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> ExtensionCode="MasterAlarms"><AlarmClasses>
> 	<AlarmClass Name="Alarm" Description="Default Class for Process Alarms" 
> DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
> AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
> NormalSeverity="350" ActiveSeverity="500" />
> 	<AlarmClass Name="Trip" Description="Default Class for Convertor Trips" 
> DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
> AckBackgroundColor="White" AckForegroundColor="Maroon" IsIntrinsic="true" 
> NormalSeverity="350" ActiveSeverity="500" />
> 	<AlarmClass Name="System" Description="Default Class for WorkstationST 
> System alarms" DescAlt="" NormalBackgroundColor="White" 
> NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
> AlarmForegroundColor="White" AckBackgroundColor="White" 
> AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
> ActiveSeverity="500" />
> 	<AlarmClass Name="Diagnostic" Description="Default Class for Process 
> Diagnostics" DescAlt="" NormalBackgroundColor="White" 
> NormalForegroundColor="Black" AlarmBackgroundColor="Red" 
> AlarmForegroundColor="White" AckBackgroundColor="White" 
> AckForegroundColor="Red" IsIntrinsic="true" NormalSeverity="350" 
> ActiveSeverity="500" />
> 	<AlarmClass Name="Hold" Description="Default Class for Holds" DescAlt="" 
> NormalBackgroundColor="White" NormalForegroundColor="Black" 
> AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> NormalSeverity="350" ActiveSeverity="500" />
> 	<AlarmClass Name="Diag" Description="Default Class for Process Diagnostics" 
> DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
> AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
> NormalSeverity="350" ActiveSeverity="500" />
> 	<AlarmClass Name="Sys" Description="Default Class for WorkstationST System 
> alarms" DescAlt="" NormalBackgroundColor="White" 
> NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
> AlarmForegroundColor="White" AckBackgroundColor="White" 
> AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
> ActiveSeverity="500" />
> 	<AlarmClass Name="TEST" Description="Test Alarm Class" DescAlt="" 
> NormalBackgroundColor="White" NormalForegroundColor="Black" 
> AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
> AckBackgroundColor="White" AckForegroundColor="Maroon" NormalSeverity="350" 
> ActiveSeverity="500" />
> 	<AlarmClass Name="OpSet" Description="Alarm Class for Operator Setpoint 
> Events" DescAlt="" NormalBackgroundColor="White" 
> NormalForegroundColor="Black" AlarmBackgroundColor="Yellow" 
> AlarmForegroundColor="Black" AckBackgroundColor="Black" 
> AckForegroundColor="Yellow" IsIntrinsic="true" NormalSeverity="350" 
> ActiveSeverity="500" />
> 	<AlarmClass Name="SOE" Description="Default Class for Sequence of event" 
> DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> NormalSeverity="350" ActiveSeverity="500" />
> 	<AlarmClass Name="Event" Description="Default Class for Process Events" 
> DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> NormalSeverity="350" ActiveSeverity="500" />
> </AlarmClasses></EGDConfigExtension>
> 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> ExtensionCode="MasterHmiResources"><HmiResources>
> 	<HmiResource Name="hgyugyg" />
> </HmiResources></EGDConfigExtension>
> 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> ExtensionCode="MasterPlantAreas"><PlantAreas>
> 	<PlantAreaPath Path="Plant" />
> 	<PlantAreaPath Path="Plant.PlantArea01" />
> 	<PlantAreaPath Path="Plant.PlantArea01.PlantArea21" />
> 	<PlantAreaPath Path="Plant.PlantArea02" />
> 	<PlantAreaPath Path="Plant.PlantArea04" />
> 	<PlantAreaPath Path="Plant.PlantArea14" />
> 	<PlantAreaPath Path="Plant.PlantArea15" />
> </PlantAreas></EGDConfigExtension>
> </MasterEgdSymbolTable>
> 
0
rickshaw (7)
10/26/2006 8:53:02 PM
Hi Rick,

Thanks for providing me with the xml file and the code. According to your 
description, I installed the two hotfixes on my machine and tried to 
reproduce it on my machine. However, the code works fine and I didn't get 
an infinate loop. I also set some breakpoints in the code and check for the 
LineNumber and LinePosition properties. They are advancing properly.

Have you tried this code on another machine? If it is in an infinate loop, 
did the thread hang?

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.)

0
v-kevy (347)
10/27/2006 5:40:45 AM
Hi Kevin,

Yes, this is happening on several PCs.  I could get you a dump from windbg 
if you want.

If it makes a difference, I'm running the code from a Windows Form in the 
constructor.  Here is the VS2005 callstack:
 	System.Xml.dll!System.Xml.XmlTextReaderImpl.ParseQName(bool isQName = 
true, int startOffset, out int colonPos = -1) + 0x10f bytes	
 	System.Xml.dll!System.Xml.XmlTextReaderImpl.IncrementalRead() + 0x508 bytes	
 	System.Xml.dll!System.Xml.XmlTextReaderImpl.IncrementalRead(System.Array 
array, int index, int count) + 0x79 bytes	
 	System.Xml.dll!System.Xml.XmlTextReaderImpl.ReadChars(char[] buffer, int 
index, int count) + 0xbc bytes	
 	System.Xml.dll!System.Xml.XmlTextReader.ReadChars(char[] buffer, int 
index, int count) + 0x15 bytes	
>	ReadCharsSample.exe!ReadCharsSample.Form1.ReadElementBodyAsXml(System.Xml.XmlTextReader reader = {Element, Name="EGDConfigExtension"}) Line 46 + 0x15 bytes	C#
 	ReadCharsSample.exe!ReadCharsSample.Form1.ReadXml() Line 29 + 0x9 bytes	C#
 	ReadCharsSample.exe!ReadCharsSample.Form1.Form1() Line 18 + 0x7 bytes	C#
 	ReadCharsSample.exe!ReadCharsSample.Program.Main() Line 17 + 0x13 bytes	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, 
System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x32 bytes	
 
	Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2b bytes	
 	mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object 
state) + 0x3b bytes	
 
	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext 
executionContext, System.Threading.ContextCallback callback, object state) + 
0x81 bytes	
 	mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x40 bytes	


The loaded modules are:

'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', 
No symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', 
Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\ReadCharsXmlIssue\ReadCharsSample\bin\Debug\ReadCharsSample.vshost.exe', 
Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Symbols loaded.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Symbols loaded.
The thread 0x60c has exited with code 0 (0x0).
The thread 0x1548 has exited with code 0 (0x0).
SRCSRV: The module 
'C:\ReadCharsXmlIssue\ReadCharsSample\bin\Debug\ReadCharsSample.exe' does not 
contain source server information.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\ReadCharsXmlIssue\ReadCharsSample\bin\Debug\ReadCharsSample.exe', Symbols 
loaded.
SRCSRV: The module 
'C:\ReadCharsXmlIssue\ReadCharsSample\bin\Debug\ReadCharsSample.exe' does not 
contain source server information.
'ReadCharsSample.vshost.exe' (Managed): Loaded 
'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Symbols loaded.
SRCSRV: The module 
'C:\ReadCharsXmlIssue\ReadCharsSample\bin\Debug\ReadCharsSample.exe' does not 
contain source server information.
SRCSRV: The module 
'C:\ReadCharsXmlIssue\ReadCharsSample\bin\Debug\ReadCharsSample.exe' does not 
contain source server information.
SRCSRV: The module 
'C:\ReadCharsXmlIssue\ReadCharsSample\bin\Debug\ReadCharsSample.exe' does not 
contain source server information.

-- 
Rick


"Kevin Yu [MSFT]" wrote:

> Hi Rick,
> 
> Thanks for providing me with the xml file and the code. According to your 
> description, I installed the two hotfixes on my machine and tried to 
> reproduce it on my machine. However, the code works fine and I didn't get 
> an infinate loop. I also set some breakpoints in the code and check for the 
> LineNumber and LinePosition properties. They are advancing properly.
> 
> Have you tried this code on another machine? If it is in an infinate loop, 
> did the thread hang?
> 
> 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.)
> 
> 
0
rickshaw (7)
10/27/2006 9:50:01 AM
More information....  I tried just copying the text from my XML into a file 
and as you reported... it reads correctly.

What I missed when pasting the XML in the post, we create our XML with UTF8 
encoding, so the XmlTextWriter writes 3 bytes in the begining of the file.  
If these 3 bytes are not present, ReadChars reads fine.  If they are present, 
I get the hang up.

The basic code we use to create an XML file is:
			FileStream fileStream = new FileStream(@"NewFile.xml", FileMode.Create, 
FileAccess.Write);
			XmlTextWriter writer = new XmlTextWriter(fileStream, Encoding.UTF8);

....
write the xml
....
			writer.Close();

The 3 bytes at the begining of the file are EF BB BF in value.
-- 
Rick


"Rick" wrote:

> I forgot to mention, the infinate loop is in .Net Framework 2.0.  I have the 
> hotfixes (KB924895 and KB922271) (as well as 2 security updates) installed.
> -- 
> Rick
> 
> 
> "Rick" wrote:
> 
> > The following code will enter an infinate loop when in ReadChars.  I can only 
> > make it happen when reading a Stream and with this particular XML.  If I use 
> > the ReadInnerXml call rather than my own ReadElementBodyAsXml the code works, 
> > but is less efficent.  ReadElementBodyAsXml is required by my application 
> > with .Net Framework 1.1.
> > 
> > The code breaks on the second call to ReadElementBodyAsXml with the inner xml:
> > </EGDConfigExtension>
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterHmiResources"><HmiResources>
> > 	<HmiResource Name="hgyugyg" />
> > </HmiResources></EGDConfigExtension>
> > 
> > 
> > This is bad behavior, so I felt it should be posted.  Maybe it is already 
> > know to be fixed in SP1 (hopefully forthcoming).
> > 
> > Regards,
> > Rick
> > 
> > --- code that breaks ---
> > 		private void ReadXml()
> > 		{
> > 			FileStream fs = File.OpenRead(@"MasterSymbolTable.xml");
> > 			XmlTextReader reader = new XmlTextReader(fs, XmlNodeType.Element, null);
> > 			reader.MoveToContent();
> > 			reader.ReadToDescendant("EGDConfigExtension");
> > 			string xml = ReadElementBodyAsXml(reader);
> > 			reader.Read();
> > 			xml = ReadElementBodyAsXml(reader);
> > 		}
> > 
> > 		private string ReadElementBodyAsXml(XmlTextReader reader)
> > 		{
> > 			int startingLineNumber = reader.LineNumber;
> > 			int startingLinePosition = reader.LinePosition;
> > 			int startingDepth = reader.Depth;
> > 			bool startingElementIsEmpty = reader.IsEmptyElement;
> > 			string startingName = reader.Name;
> > 
> > 			System.Diagnostics.Debug.Assert(reader.NodeType == XmlNodeType.Element, 
> > "Node type must be Element.",
> > 				"ReadElementBodyAsXml should be called when the reader is positioned on 
> > an element.  It will simply return null if it is not, but the intention is 
> > for it to be used to read element content.");
> > 
> > 			char[] buffer = new char[512];
> > 			int totalRead = 0;
> > 			int i;
> > 			while ((i = reader.ReadChars(buffer, totalRead, buffer.Length - 
> > totalRead)) > 0)
> > 			{
> > 				totalRead += i;
> > 				if (reader.Depth <= startingDepth)
> > 				{
> > 					// Even though we read chars, the LineNumber and LinePosition do not 
> > change
> > 					// unless we read a node.  We don't want to read any more unless we are
> > 					// on a child node.  But we also need to make sure that we are not still
> > 					// on the same node that we started with, since we could have some very
> > 					// big nodes.  It is hard to tell if ReadChars returned because it did
> > 					// not have any more content buffered or if it got to the end of a node.
> > 					// If at the end of a node, which node?
> > 					// This code fixes SCR 2923.
> > 					if (reader.NodeType != XmlNodeType.Element)
> > 						break; // We must not be on the node we started on.
> > 				}
> > 				if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 
> > startingDepth)
> > 					break;
> > 				if (totalRead == buffer.Length)
> > 				{
> > 					char[] newBuf = new char[buffer.Length + 512];
> > 					Buffer.BlockCopy(buffer, 0, newBuf, 0, totalRead * 2); // Each char is 
> > 2 bytes.
> > 					buffer = newBuf;
> > 				}
> > 			}
> > 
> > 			string innerXml = null;
> > 			if (totalRead > 0)
> > 				innerXml = new string(buffer, 0, totalRead);
> > 			else
> > 				innerXml = null;
> > 
> > 			return innerXml;
> > 		}
> > 
> > 
> > 
> > -----  XML file MasterSymbolTable.Xml  ---
> > <?xml version="1.0" encoding="utf-8"?>
> > <?GeCssClass type="GeIndsysNetworkCoe.EgdConfig.EgdMasterSymbolTable, 
> > EgdCoeConfig"?>
> > <MasterEgdSymbolTable EGDSpecVersion="3.04" ConfigTimeSecs="1160762827" 
> > ConfigTimeNSecs="704238500" xmlns="http://geindustrial.com/EGD" Name="Demo">
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterAlarms"><AlarmClasses>
> > 	<AlarmClass Name="Alarm" Description="Default Class for Process Alarms" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Trip" Description="Default Class for Convertor Trips" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Maroon" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="System" Description="Default Class for WorkstationST 
> > System alarms" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
> > AlarmForegroundColor="White" AckBackgroundColor="White" 
> > AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="Diagnostic" Description="Default Class for Process 
> > Diagnostics" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Red" 
> > AlarmForegroundColor="White" AckBackgroundColor="White" 
> > AckForegroundColor="Red" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="Hold" Description="Default Class for Holds" DescAlt="" 
> > NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> > AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Diag" Description="Default Class for Process Diagnostics" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Sys" Description="Default Class for WorkstationST System 
> > alarms" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
> > AlarmForegroundColor="White" AckBackgroundColor="White" 
> > AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="TEST" Description="Test Alarm Class" DescAlt="" 
> > NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Maroon" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="OpSet" Description="Alarm Class for Operator Setpoint 
> > Events" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Yellow" 
> > AlarmForegroundColor="Black" AckBackgroundColor="Black" 
> > AckForegroundColor="Yellow" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="SOE" Description="Default Class for Sequence of event" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> > AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Event" Description="Default Class for Process Events" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> > AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > </AlarmClasses></EGDConfigExtension>
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterHmiResources"><HmiResources>
> > 	<HmiResource Name="hgyugyg" />
> > </HmiResources></EGDConfigExtension>
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterPlantAreas"><PlantAreas>
> > 	<PlantAreaPath Path="Plant" />
> > 	<PlantAreaPath Path="Plant.PlantArea01" />
> > 	<PlantAreaPath Path="Plant.PlantArea01.PlantArea21" />
> > 	<PlantAreaPath Path="Plant.PlantArea02" />
> > 	<PlantAreaPath Path="Plant.PlantArea04" />
> > 	<PlantAreaPath Path="Plant.PlantArea14" />
> > 	<PlantAreaPath Path="Plant.PlantArea15" />
> > </PlantAreas></EGDConfigExtension>
> > </MasterEgdSymbolTable>
> > 
0
rickshaw (7)
10/27/2006 1:20:02 PM
Rick wrote:


> The 3 bytes at the begining of the file are EF BB BF in value.

That is the BOM (byte order mark for UTF-8), you can avoid that by using 
e.g.

XmlTextWriter writer = new XmlTextWriter(fileStream, new 
UTF8Encoding(true));

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
10/27/2006 4:07:59 PM
Martin Honnen wrote:
> Rick wrote:
> 
> 
>> The 3 bytes at the begining of the file are EF BB BF in value.
> 
> That is the BOM (byte order mark for UTF-8), you can avoid that by using 
> e.g.
> 
> XmlTextWriter writer = new XmlTextWriter(fileStream, new 
> UTF8Encoding(true));

I misread the API, you need e.g.

XmlTextWriter writer = new XmlTextWriter(fileStream, new 
UTF8Encoding(false));

to avoid the BOM.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
10/27/2006 4:10:09 PM
Should I avoid writing the BOM or is that required to tell a reader the 
content is UTF8 encoded?  My feeling is these bytes should be there.  I want 
unicode in my XML.

Also, if the BOM was writen by XMLTextWriter, should the XMLTextReader's 
ReadChars exhibit the infinite loop behavior?
-- 
Rick


"Martin Honnen" wrote:

> Martin Honnen wrote:
> > Rick wrote:
> > 
> > 
> >> The 3 bytes at the begining of the file are EF BB BF in value.
> > 
> > That is the BOM (byte order mark for UTF-8), you can avoid that by using 
> > e.g.
> > 
> > XmlTextWriter writer = new XmlTextWriter(fileStream, new 
> > UTF8Encoding(true));
> 
> I misread the API, you need e.g.
> 
> XmlTextWriter writer = new XmlTextWriter(fileStream, new 
> UTF8Encoding(false));
> 
> to avoid the BOM.
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 
0
rickshaw (7)
10/27/2006 5:23:02 PM
Rick wrote:
> Should I avoid writing the BOM or is that required to tell a reader the 
> content is UTF8 encoded?  My feeling is these bytes should be there.  I want 
> unicode in my XML.

For UTF-8 the BOM is optional, see
   <http://www.unicode.org/faq/utf_bom.html#BOM>

> Also, if the BOM was writen by XMLTextWriter, should the XMLTextReader's 
> ReadChars exhibit the infinite loop behavior?

Usually Microsoft's XML parsers know how to deal with an UTF-8 BOM. I am 
not sure why you get the loop problem but I have not read the complete 
thread. I mainly tried to explain what the bytes you see are and to 
provide a work around.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
10/27/2006 5:39:01 PM
Thanks for the post.    Again, a workaround is for me to use ReadInnerXml 
rather than building my own.  The method using ReadChars was required in .Net 
framework 1.1, but ReadInnerXml works for 2.0.  The side effect is poorer 
performance, so I'm interested if ReadChars could be fixed in a future .Net 
framework release.  I want to stick to writing the BOM for legacy reasons.  I 
have a lot of production code writing the BOM that I'll need to support 
reading.
-- 
Rick


"Martin Honnen" wrote:

> Rick wrote:
> > Should I avoid writing the BOM or is that required to tell a reader the 
> > content is UTF8 encoded?  My feeling is these bytes should be there.  I want 
> > unicode in my XML.
> 
> For UTF-8 the BOM is optional, see
>    <http://www.unicode.org/faq/utf_bom.html#BOM>
> 
> > Also, if the BOM was writen by XMLTextWriter, should the XMLTextReader's 
> > ReadChars exhibit the infinite loop behavior?
> 
> Usually Microsoft's XML parsers know how to deal with an UTF-8 BOM. I am 
> not sure why you get the loop problem but I have not read the complete 
> thread. I mainly tried to explain what the bytes you see are and to 
> provide a work around.
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 
0
rickshaw (7)
10/27/2006 6:01:02 PM
Hi Rick,

Thanks for the information you have provided. I think this is the UTF8 
problem. As you know, the 3 bytes should be there for a UTF8 encoded text 
file.

In my opinion, you have to keep the UTF8 formatting when producing the xml 
file. When reading it, tell the XmlTextReader that it is UTF8 encoded. 
Because some UTF8 encoded file doesn't have BOM. So, let the XmlTextReader 
handle it will be the best solution. 

If you don't let it know about the UTF8 encoding, the code will surely fell 
into some expected behavior.

If this does not help for you to resolved the problem, please feel free to 
let me know.

Kevin Yu
Microsoft Online Community Support
==================================================

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

0
v-kevy (347)
10/30/2006 6:42:27 AM
Thank you Kevin,

Sorry but I'm still confused.  When the 3 byte BOM is present and my code 
constructs the XmlTextReader with the file stream pointing to the UTF8 BOM 
file, after I execute the first reader.MoveToContent, I can see the 
reader.Encoding property is set to UTF8.  Then as it reads further, the 
infinite loop occurs.

You said I should tell the reader to expect UTF8.  How would I do that?

Thanks,
-- 
Rick


"Kevin Yu [MSFT]" wrote:

> Hi Rick,
> 
> Thanks for the information you have provided. I think this is the UTF8 
> problem. As you know, the 3 bytes should be there for a UTF8 encoded text 
> file.
> 
> In my opinion, you have to keep the UTF8 formatting when producing the xml 
> file. When reading it, tell the XmlTextReader that it is UTF8 encoded. 
> Because some UTF8 encoded file doesn't have BOM. So, let the XmlTextReader 
> handle it will be the best solution. 
> 
> If you don't let it know about the UTF8 encoding, the code will surely fell 
> into some expected behavior.
> 
> If this does not help for you to resolved the problem, please feel free to 
> let me know.
> 
> Kevin Yu
> Microsoft Online Community Support
> ==================================================
> 
> (This posting is provided "AS IS", with no warranties, and confers no 
> rights.)
> 
> 
0
rickshaw (7)
10/30/2006 10:11:01 AM
Hi Rick

What I mean to tell the reader to expect UTF8 is to specify UTF8 encoding 
in the XmlTextReader constructor like Martin suggested.

XmlTextWriter writer = new XmlTextWriter(fileStream, new 
UTF8Encoding(false));

Since you can see the Encoding property has been set to UTF8, it's fine. I 
tried on my machine with a UTF8 xml with BOM, it is working fine. If you 
still get an infinite loop on this machine, does it happen on another one?

If it still doesn't work for you, I think you have to use ReadInnerXml 
instead. In my opinion, there will not be much difference in performance if 
the Xml is not too big.

I'm sorry for didn't help much.

Kevin Yu
Microsoft Online Community Support
==================================================

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

0
v-kevy (347)
10/31/2006 3:35:22 AM
Hello Rick,

This looks like bug in the XmlTextReader. I don't think it is related to the 
UTF-8 BOM. The BOM might be just affecting internal buffer alignment. Could 
you please send me the XML file so I can take a look why it is looping and 
file a bug?

Thank you,
-Helena Kotas [MSFT]

"Rick" wrote:

> I forgot to mention, the infinate loop is in .Net Framework 2.0.  I have the 
> hotfixes (KB924895 and KB922271) (as well as 2 security updates) installed.
> -- 
> Rick
> 
> 
> "Rick" wrote:
> 
> > The following code will enter an infinate loop when in ReadChars.  I can only 
> > make it happen when reading a Stream and with this particular XML.  If I use 
> > the ReadInnerXml call rather than my own ReadElementBodyAsXml the code works, 
> > but is less efficent.  ReadElementBodyAsXml is required by my application 
> > with .Net Framework 1.1.
> > 
> > The code breaks on the second call to ReadElementBodyAsXml with the inner xml:
> > </EGDConfigExtension>
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterHmiResources"><HmiResources>
> > 	<HmiResource Name="hgyugyg" />
> > </HmiResources></EGDConfigExtension>
> > 
> > 
> > This is bad behavior, so I felt it should be posted.  Maybe it is already 
> > know to be fixed in SP1 (hopefully forthcoming).
> > 
> > Regards,
> > Rick
> > 
> > --- code that breaks ---
> > 		private void ReadXml()
> > 		{
> > 			FileStream fs = File.OpenRead(@"MasterSymbolTable.xml");
> > 			XmlTextReader reader = new XmlTextReader(fs, XmlNodeType.Element, null);
> > 			reader.MoveToContent();
> > 			reader.ReadToDescendant("EGDConfigExtension");
> > 			string xml = ReadElementBodyAsXml(reader);
> > 			reader.Read();
> > 			xml = ReadElementBodyAsXml(reader);
> > 		}
> > 
> > 		private string ReadElementBodyAsXml(XmlTextReader reader)
> > 		{
> > 			int startingLineNumber = reader.LineNumber;
> > 			int startingLinePosition = reader.LinePosition;
> > 			int startingDepth = reader.Depth;
> > 			bool startingElementIsEmpty = reader.IsEmptyElement;
> > 			string startingName = reader.Name;
> > 
> > 			System.Diagnostics.Debug.Assert(reader.NodeType == XmlNodeType.Element, 
> > "Node type must be Element.",
> > 				"ReadElementBodyAsXml should be called when the reader is positioned on 
> > an element.  It will simply return null if it is not, but the intention is 
> > for it to be used to read element content.");
> > 
> > 			char[] buffer = new char[512];
> > 			int totalRead = 0;
> > 			int i;
> > 			while ((i = reader.ReadChars(buffer, totalRead, buffer.Length - 
> > totalRead)) > 0)
> > 			{
> > 				totalRead += i;
> > 				if (reader.Depth <= startingDepth)
> > 				{
> > 					// Even though we read chars, the LineNumber and LinePosition do not 
> > change
> > 					// unless we read a node.  We don't want to read any more unless we are
> > 					// on a child node.  But we also need to make sure that we are not still
> > 					// on the same node that we started with, since we could have some very
> > 					// big nodes.  It is hard to tell if ReadChars returned because it did
> > 					// not have any more content buffered or if it got to the end of a node.
> > 					// If at the end of a node, which node?
> > 					// This code fixes SCR 2923.
> > 					if (reader.NodeType != XmlNodeType.Element)
> > 						break; // We must not be on the node we started on.
> > 				}
> > 				if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 
> > startingDepth)
> > 					break;
> > 				if (totalRead == buffer.Length)
> > 				{
> > 					char[] newBuf = new char[buffer.Length + 512];
> > 					Buffer.BlockCopy(buffer, 0, newBuf, 0, totalRead * 2); // Each char is 
> > 2 bytes.
> > 					buffer = newBuf;
> > 				}
> > 			}
> > 
> > 			string innerXml = null;
> > 			if (totalRead > 0)
> > 				innerXml = new string(buffer, 0, totalRead);
> > 			else
> > 				innerXml = null;
> > 
> > 			return innerXml;
> > 		}
> > 
> > 
> > 
> > -----  XML file MasterSymbolTable.Xml  ---
> > <?xml version="1.0" encoding="utf-8"?>
> > <?GeCssClass type="GeIndsysNetworkCoe.EgdConfig.EgdMasterSymbolTable, 
> > EgdCoeConfig"?>
> > <MasterEgdSymbolTable EGDSpecVersion="3.04" ConfigTimeSecs="1160762827" 
> > ConfigTimeNSecs="704238500" xmlns="http://geindustrial.com/EGD" Name="Demo">
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterAlarms"><AlarmClasses>
> > 	<AlarmClass Name="Alarm" Description="Default Class for Process Alarms" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Trip" Description="Default Class for Convertor Trips" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Maroon" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="System" Description="Default Class for WorkstationST 
> > System alarms" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
> > AlarmForegroundColor="White" AckBackgroundColor="White" 
> > AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="Diagnostic" Description="Default Class for Process 
> > Diagnostics" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Red" 
> > AlarmForegroundColor="White" AckBackgroundColor="White" 
> > AckForegroundColor="Red" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="Hold" Description="Default Class for Holds" DescAlt="" 
> > NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> > AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Diag" Description="Default Class for Process Diagnostics" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Red" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Red" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Sys" Description="Default Class for WorkstationST System 
> > alarms" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Teal" 
> > AlarmForegroundColor="White" AckBackgroundColor="White" 
> > AckForegroundColor="Teal" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="TEST" Description="Test Alarm Class" DescAlt="" 
> > NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Maroon" AlarmForegroundColor="White" 
> > AckBackgroundColor="White" AckForegroundColor="Maroon" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="OpSet" Description="Alarm Class for Operator Setpoint 
> > Events" DescAlt="" NormalBackgroundColor="White" 
> > NormalForegroundColor="Black" AlarmBackgroundColor="Yellow" 
> > AlarmForegroundColor="Black" AckBackgroundColor="Black" 
> > AckForegroundColor="Yellow" IsIntrinsic="true" NormalSeverity="350" 
> > ActiveSeverity="500" />
> > 	<AlarmClass Name="SOE" Description="Default Class for Sequence of event" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> > AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > 	<AlarmClass Name="Event" Description="Default Class for Process Events" 
> > DescAlt="" NormalBackgroundColor="White" NormalForegroundColor="Black" 
> > AlarmBackgroundColor="Yellow" AlarmForegroundColor="Black" 
> > AckBackgroundColor="Black" AckForegroundColor="Yellow" IsIntrinsic="true" 
> > NormalSeverity="350" ActiveSeverity="500" />
> > </AlarmClasses></EGDConfigExtension>
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterHmiResources"><HmiResources>
> > 	<HmiResource Name="hgyugyg" />
> > </HmiResources></EGDConfigExtension>
> > 	<EGDConfigExtension Company="http://pdweb.salem.ge.com" 
> > ExtensionCode="MasterPlantAreas"><PlantAreas>
> > 	<PlantAreaPath Path="Plant" />
> > 	<PlantAreaPath Path="Plant.PlantArea01" />
> > 	<PlantAreaPath Path="Plant.PlantArea01.PlantArea21" />
> > 	<PlantAreaPath Path="Plant.PlantArea02" />
> > 	<PlantAreaPath Path="Plant.PlantArea04" />
> > 	<PlantAreaPath Path="Plant.PlantArea14" />
> > 	<PlantAreaPath Path="Plant.PlantArea15" />
> > </PlantAreas></EGDConfigExtension>
> > </MasterEgdSymbolTable>
> > 
0
11/8/2006 8:34:02 PM
Reply:

Similar Artilces:

Conditional format
Hi Conditional format Is there a way to get a cell's format determined by the format of a different cell?! e.g. Could one get an entire row market up in say bold red if one cell in that row was say less than 100 With thanks Ship Shiperton Henethe Hi Shiperton yep ) select the rows that you want to apply the conditional formatting to, ensuring that the first row of this group is the first row at the top of the screen (it gets confused sometimes if it isn't) the following example assums you've selected from row 2 onwards and you want the row to turn red if ...

Entering Data to make a list?
Is there a way that when I enter something into A1 &B1 it will fill down on a List? Like if I type apples in A1 & $12 in B1 on a certain sheet it will copy Apples and $12 , then if I type Pears & $5 it will copy to the next blank cell and so on -- Thanks in advance for your help....Bob Vance .. .. .. .. Bob I'm assuming you have this list on another sheet. This little macro will do the following: When you enter something in B1 of the first sheet, it will copy A1:B1 to the bottom of the list in Columns A & B of the second sheet. It will then clear (erase) the conte...

CD/DVD can't "see" CDs after Windows Vista update (KB973917)
Ever since this update installed, my CD/DVD drive does not see any CD or DVD I put in the drive. I have looked for an updated driver and have the most recent driver. I have uninstalled the driver and reinstalled it, both with and without shutting down the laptop and starting it up again. Device Manager says the device is working properly, which it clearly isn't. I am wondering if I should uninstall the update. Lisa This sometimes happens Go into the Registry and search for Upper and Lower Filters. When found delete both of them. Close out and Save and then reboot. ...

Can you compile Excell vba to keep code Non-Viewable ?
Is there a way to protect your vba code in an excel app? thanks - tmb Hi, In the Visual Basic Editor, Right click on the module Node that you want to protect, select the protection tab, and enter a password. this will protect your VBA code. Hope this helps Sunil Jayakumar "tmb" <topmailbox@yahoo.com> wrote in message news:bwe3e.12668$vd.7397@tornado.tampabay.rr.com... > Is there a way to protect your vba code in an excel app? > > thanks - tmb > > > www.ayyoo.com/credit-cards.html Just to add to Sunil's post. This will keep most people fro...

Not allow entering repeated references in a column
Frank, Sorted! :) :) :) ... sth was missing (<) The formula to be used is =COUNTIF($A$1:$A$25,A1)<=1 and NOT =COUNTIF($A$1:$A$25,A1)=1 ... little things make the difference, isn�t it ;) ? Thank you very much for your support and your time. Ritinh -- ritinh ----------------------------------------------------------------------- ritinha's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1566 View this thread: http://www.excelforum.com/showthread.php?threadid=27195 ...

Excel 2007 VBA
Hi, I have a number of scenarios that I need to perform some calculations on. I am trying to keep the code short by having a for - next loop running through all the scenarios. I am not having much luck getting that to work, though. Shouldn't the following work? For intLooping = 1 To 20 Scenarios(intLooping).Show Next The following, on the other hand, does work (but doesn't do any good). For intScenNr = 1 To 20 arrScenarios(intScenNr - 1) = Scenarios(intScenNr).Name Next MsgBox Scenarios(1).Name & " - to - " &...

must read
...

I can't see microsoft.public.publisher.webdesign
I want to post a question about my website, and have noticed requests that those questions go to microsoft.public.publisher.webdesign. I have verizon FIOS and use news.verizon.net. That group is not in the list. I just talked to techinal support and they said there is no way to request a newsgroup be put in the verizon newsgroup server. Can it be possible that no one using that group is using verizon newgroups?! I'm using Outlook Express 6. I click on news.verizon.net, then Reset List. If I type microsoft.public.pub I can see *this* group, but not publisher.webdesign. I would rat...

Can Anyone Help me?
Hi, I'm new to Pub 2003. I am creating an advert. I have used the rectangular 'auto-shape' and filled it with a transparent fade to black. Ofcourse it is very important that it is transparent, but when I come to print it, it appears as a solid rectangle. Does anyone know how to change this and basically print how you see it on the screen?? Many thanks, Ben Publisher has always had problems with transparency. Create your auto-shape with your preferred transparency. Right-click, save as picture. Choose .png. Re-insert into your publication. -- Mary Sauer http://msauer.mv...

Can't download hotmail messages after installing Explorer 7
I'm running Outlook 2002 (10.4219.4219) SP-2 and have not been able to download my Hotmail folders/messages since installing Internet Explorer (ver. 7.0.5730.11IS). Goes on a loop requesting username and password for the hotmail server. I have no problem accessing my Hotmail account via the long way Any comments/suggestions? Callaway <nospam@yahoo.com> wrote: > I'm running Outlook 2002 (10.4219.4219) SP-2 and have not been able to > download my Hotmail folders/messages since installing Internet > Explorer (ver. 7.0.5730.11IS). Goes on a loop requesting userna...

Can
I need an IF then state to Edit/paste special/value into the cell so that the value only remains, not the function. I only want it to calculate once. Is there an easy way? Thank you Hi Ron this can not be done with a formula, you need to use VBA code ... this can be done "automatically" via a Worksheet_Change procedure, e.g. Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Target.Address = "$A$1" And Target.Value <> "" Then Range("A3").Copy Range("A3").PasteSpecial (xl...

Date Changes to 01/00/00 when i enter any date.
Using XL2003, I have a problem. When i enter a date in cell, such as 08/25/10, or use the shortcut Ctrl ;, XL displays 01/00/00 in the cell instead. I have formatted the cell as a date. What can I do to fix this problem? Thank you so much. Tonso ...

Can't see macro
I am experimenting with a macro from David McRitchie's page: I create a custom button, and when I try to assign the macro, it is not in my options. It is in the workbook. What am I doing wrong? All the other macros are there. Joe Sub Insert_Rows_And_Fill_Formulas(Optional vRows As Long) ' Documented: http://www.mvps.org/dmcritchie/excel/insrtrow.htm ' Re: Insert Rows -- 1997/09/24 Mark Hill <markhill@charm.net.noSpam> 'Dim vRows As Integer ' row selection based on active cell -- rev. 2000-09-02 David McRitchie ActiveCell.EntireRow.Select 'So you do n...

can't setup my account
I'm at work trying to set up my Outlook account but I keep getting the username/password box pop up after I make my account. Here's whats happening: I'm selecting POP3 --> setting incoming mail server (POP3)/outgoing(SMTP) as the same, typing in my name, email address, user name, and password. Then I click more settings-->Advanced--> Incoming server (POP3) = 110 and Outgoing server (SMTP) = 587. When I go to test settings I type in my User Name and Password but the box just pops up again in 10 seconds. Why isn't it accepting my password? I can't send mail...

Multple calendars in one user
I am trying to get multiple calendars set up under one user and some of the events would be shared between different ones. I can not find how to essentially invite myself to an event between the different calendars. You are allowed to create the different calendars but you are not allowed to share events between them. Anyone done this before? Create a meeting request in the non-default calendar and invite yourself. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by ...

Sound when entering transaction into account
I just upgraded to Money 2004 from Money V5. Is it possible to change the lame "ding" sound when entering a transaction to the satisfying "ka-ching" sound in Version 5? -- Norm Although Money parameters turn on whether sounds are played, the actual sounds are stored in the system level. So go to the Start and select control panel. In the control panel select "Sounds" (slightly different name and location depending upon which operating system. scroll down the sounds until you find Money and the "enter transaction" you can then change it ...

"read only" cell in a given worksheet
is it possible to have a particuler cell in a worksheet to be only "read only"? meaning to hae that cell be read and not to be edited be others (even preventing the view of that cell's formula). thank you. "Colin2u" <Colin2u@discussions.microsoft.com> wrote in message news:FAAE5C9B-ADF9-4AD4-AA6B-4688684ABCB9@microsoft.com... > is it possible to have a particuler cell in a worksheet to be only "read > only"? meaning to hae that cell be read and not to be edited be others > (even > preventing the view of that cell's formula). > th...

entering current time in shared work book
Hi, i am maintaing a excel tracker in shared drive where i am manually entering the time when a person came into the office. Is it possible that when a person comes he himself open the shared file and click the cell corresponding to his name so that the time of that moment can be stored and that can not be further updated with new value (time)... below is the format Name of Person Date Name A Name B Name C 21-Apr-10 6:44 PM 6:48 PM 6:40 PM 22-Apr-10 6:30 PM 6:34 PM 6:31 PM 23-Apr-10 6:35 PM 6:39 PM 6:40 PM I would try first to setup a list on another she...

how can I put a watermark in excel?
I want to put a watermark (text or a picture, I'll scan it in) on an Excel template. Hi You can use Word Art, remove the lines, color with 25% gray, click semi-transparent (or in latest version set the transparency to your desire). Rotate to desired angle. On the screen, when you type over the mark, it looks a bit fuzzy but prints out wonderfully If you have many to do try this: Here is some code from L. Howard Kittle. In this Zip file you can find 4 example workbooks with code to insert watermarks in to your pages. 1 : Watermark Horizontal LANDSCAPE 2 : Watermark Horizontal PORTR...

Read a file into a _bstr_t
What's the quickest way to read a file into a _bstr_t. (its actually an XML file) -- Michael Tissington http://www.oaklodge.com http://www.tabtag.com Meaningless question. What is the format of the file? 8-bit characters or 16-bit characters? How large is it, that "quickest" has any meaning? If it isn't hundreds of megabytes, the topic is not even worthy of discussion, because disk rotational latency will exceed actual byte transfer time to your buffer by five or six orders of magnitude. And if it is 8-bit characters, it is also a meaningless question, because the ans...

Can a front-end server be a bridgehead at the same time?
Is such a configuration even recommended? (Personally, I don't see why not.) Thanks. On Thu, 16 Jun 2005 17:34:23 GMT, "jdee" <jdee@trunk.net> wrote: >Is such a configuration even recommended? > >(Personally, I don't see why not.) > >Thanks. > it's fine, it's supported, it's recommended. Yar. Do it all the time. Just remember you need to leave that first storage group & mailstore up and running. -- Thanks, Brian Desmond Windows Server MVP www.briandesmond.com "jdee" <jdee@trunk.net> wrote in message news:zK...

Is it possible and how can it be done?
I have a table looking like this: Id TaskLeader PreviousId .... 4 Hans 2 5 Kari 7 6 John 5 7 Jim 4 8 Kari 6 I'm wondering if it's possible to make a query that give me this result below (and of course if it's possible; how) ?: Id Leader Previous Leader 8 Kari John 6 John Kari 5 Kari Jim 7 Jim ...

How can I reset defaults for cell borders? i.e color and/or inte.
I want to be able to modify border colors and intesity for cells in a worksheet. 1-choose the cellsformat/cells 2-choose format/cells 3-click on Border tab 4-choose the line style and color 5-click kind of vorder u want to have. 6-to reset defaults for cell borders, click "none" "mffoster" wrote: > I want to be able to modify border colors and intesity for cells in a > worksheet. ...

Can one have an extra margin gutter, for binding a document print.
I need to print Excel documents (landscape A4) on both sides of the paper, and bind them along the long edge. Thus I need an extra margin gutter along the top of odd pages, and along the bottom of even pages. (It's wasteful to put the extra margin on both top and bottom of every page...) Using Excel 2002 SP1. Hi Dave, AFAIK, Excel provides no options for true duplex printing. Headers/footers, margins, etc. are only geared for single-sided printing. You might want to consider using Word for that purpose. You have more page layout options that may give you what you want. Use Word...

can I block just one person from viewing my calendar?
Just wondering if I can block one person or individuals from viewing my outlook calendar? Are you using Exchange server? If so, yes. Add them top the permissions tab of the calendar and set it to none. (right click on the calendar and choose properties). See http://www.slipstick.com/tutorials/share/subfolders.htm - the Sharing the subfolder video has the instructions. You'll choose none for the permissions though. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook T...