R
Ralph Purtcher-Wydenbruck
This is a worrying bug, and indicates a potential problem in the Framework
CLR. This bug affected a project I was working on, which behaved differently
when run from the Visual Studio IDE than when run by double clicking on the
project's EXE file. The problem can be replicated easily:
Create a new project in Visual Studio 2003 and add the following code.
Module Main
Sub Main()
Dim xmlDoc As New System.Xml.XmlDocument
xmlDoc.AppendChild(xmlDoc.CreateElement("Root"))
Dim o, n As Object
Dim count As Integer
For Each o In xmlDoc.ChildNodes
For n = 0 To 9
count += 1
Next
Next
System.Windows.Forms.MessageBox.Show("Count: " & count)
End Sub
End Module
IMPORTANT: To replicate the bug, you must
(1) Set the project compile mode to "Release"
(2) Enable the following option: Project Configuration Properties /
Optimisations / "Remove Integer Overflow Checks"
Finally, run the program from the Visual Studio IDE. The expected message,
"Count: 10", is displayed. Now run the program from it's EXE file via
Windows Explorer. A message, "Count: 1" is displayed, which is incorrect.
CLR. This bug affected a project I was working on, which behaved differently
when run from the Visual Studio IDE than when run by double clicking on the
project's EXE file. The problem can be replicated easily:
Create a new project in Visual Studio 2003 and add the following code.
Module Main
Sub Main()
Dim xmlDoc As New System.Xml.XmlDocument
xmlDoc.AppendChild(xmlDoc.CreateElement("Root"))
Dim o, n As Object
Dim count As Integer
For Each o In xmlDoc.ChildNodes
For n = 0 To 9
count += 1
Next
Next
System.Windows.Forms.MessageBox.Show("Count: " & count)
End Sub
End Module
IMPORTANT: To replicate the bug, you must
(1) Set the project compile mode to "Release"
(2) Enable the following option: Project Configuration Properties /
Optimisations / "Remove Integer Overflow Checks"
Finally, run the program from the Visual Studio IDE. The expected message,
"Count: 10", is displayed. Now run the program from it's EXE file via
Windows Explorer. A message, "Count: 1" is displayed, which is incorrect.