[Mono-bugs] [Bug 78706][Nor] New - XmlReader's Close dosen't close file the stream

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Jun 25 12:30:17 EDT 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mtanski at wideopenwest.com.


--- shadow/78706	2006-06-25 12:30:17.000000000 -0400
+++ shadow/78706.tmp.16484	2006-06-25 12:30:17.000000000 -0400
@@ -0,0 +1,52 @@
+Bug#: 78706
+Product: Mono: Class Libraries
+Version: 1.1
+OS Details: Ubuntu
+Status: NEW   
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: mtanski at wideopenwest.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: XmlReader's Close dosen't close file the stream
+If you create an instance of XmlReader using XmlReader.Create(fileuri)
+method (instead of handing your own file stream), and then later me a call
+the Close Method on the XmlReader instance it dosen't acctualy close the
+internal filestream (untill the object gets garbage collected). This can
+lead to an IOException (Sharing violation) if you open it a second time
+(even after closing it explicitly).
+I've attached a test case tested it both on Mono (ubuntu package & current
+SVN) and on Visual Studio 2005. Visual studio does in fact close the file
+stream when the Close method is called.
+Test case
+using System;
+using System.IO;
+using System.Xml;
+namespace TestCase
+    class XmlReaderCloseCase
+    {
+        static string test_file = "test.xml";
+        static void Main()
+        {
+            // XmlReader automaticaly creates a stream for us
+            XmlReader r = XmlReader.Create(test_file);
+            // But close really dosen't close the steam (at least in mono)
+            r.Close();
+            // Exception here (only on mono, not in MS's implementation)
+            XmlTextWriter w = new XmlTextWriter(test_file, null);
+        }
+    }

More information about the mono-bugs mailing list