[Mono-bugs] [Bug 59689][Nor] New - AssemblyBuilder.Save does not release locks on resource file
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Mon, 7 Jun 2004 04:36:37 -0400 (EDT)
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 gert.driesen@pandora.be.
http://bugzilla.ximian.com/show_bug.cgi?id=59689
--- shadow/59689 2004-06-07 04:36:37.000000000 -0400
+++ shadow/59689.tmp.8516 2004-06-07 04:36:37.000000000 -0400
@@ -0,0 +1,54 @@
+Bug#: 59689
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details: Microsoft Windows XP SP1
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: gert.driesen@pandora.be
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: AssemblyBuilder.Save does not release locks on resource file
+
+The Mono AssemblyBuilder.Save (string) does not release file locks on
+resource files on Windows.
+
+The following code fragment (full source file is attached to bug report)
+will allow you to reproduce this issue (on Windows, not sure about
+linux) :
+
+string tempDir = Path.Combine (Path.GetTempPath (), "DisposeTest");
+Directory.CreateDirectory (tempDir);
+
+string resFile = Path.Combine (tempDir, "res2.txt");
+using (StreamWriter sw = new StreamWriter (resFile)) {
+ sw.WriteLine ("FOO");
+}
+
+AppDomain domain = Thread.GetDomain ();
+AssemblyName assemblyName = new AssemblyName();
+assemblyName.Name = "DisposeTestAssembly";
+
+AssemblyBuilder assemblyBuilder = domain.DefineDynamicAssembly (
+ assemblyName, AssemblyBuilderAccess.RunAndSave, tempDir);
+assemblyBuilder.DefineDynamicModule ("def_module");
+assemblyBuilder.AddResourceFile ("foo", "res2.txt",
+ resourceAttributes.Public);
+assemblyBuilder.Save ("TestAddResourceFile.dll");
+Directory.Delete(tempDir, true);
+
+When Mono tries to delete the tempdir, you'll get the following exception:
+
+Unhandled Exception: System.IO.IOException: Win32 IO returned
+ERROR_SHARING_VIOL
+ATION. Path: C:\DOCUME~1\drieseng\LOCALS~1\Temp\DisposeTest\res2.txt
+in <0x00190> System.IO.File:Delete (string)
+in <0x0009d> System.IO.Directory:RecursiveDelete (string)
+in <0x00024> System.IO.Directory:Delete (string,bool)
+in <0x00155> EntryPoint:Main ()