Переглянути джерело

Mon Feb 27 17:12:40 CET 2006 Paolo Molaro <[email protected]>

	* ModuleBuilder.cs: unlink the file before saving
	otherwise we might overwrite a file mmapped by the runtime.


svn path=/trunk/mcs/; revision=57330
Paolo Molaro 20 роки тому
батько
коміт
6acaeddd40

+ 6 - 0
mcs/class/corlib/System.Reflection.Emit/ChangeLog

@@ -1,3 +1,9 @@
+
+Mon Feb 27 17:12:40 CET 2006 Paolo Molaro <[email protected]>
+
+	* ModuleBuilder.cs: unlink the file before saving
+	otherwise we might overwrite a file mmapped by the runtime.
+
 2006-02-17  Zoltan Varga  <[email protected]>
 
 	* DynamicMethod.cs: Implement DefineParameter ().

+ 7 - 1
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs

@@ -667,7 +667,13 @@ namespace System.Reflection.Emit {
 			string fileName = fqname;
 			if (assemblyb.AssemblyDir != null)
 				fileName = Path.Combine (assemblyb.AssemblyDir, fileName);
-			
+
+			try {
+				// We mmap the file, so unlink the previous version since it may be in use
+				File.Delete (fileName);
+			} catch {
+				// We can safely ignore
+			}
 			using (FileStream file = new FileStream (fileName, FileMode.Create, FileAccess.Write))
 				WriteToFile (file.Handle);