[Mono-bugs] [Bug 79426][Nor] New - [PATCH] Assembly loader failures result in FileNotFoundException with message equal to filename

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Sep 17 11:02:04 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 gert.driesen at pandora.be.

http://bugzilla.ximian.com/show_bug.cgi?id=79426

--- shadow/79426	2006-09-17 11:02:04.000000000 -0400
+++ shadow/79426.tmp.28824	2006-09-17 11:02:04.000000000 -0400
@@ -0,0 +1,89 @@
+Bug#: 79426
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: gert.driesen at pandora.be               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [PATCH] Assembly loader failures result in FileNotFoundException with message equal to filename
+
+When an assembly cannot be loaded, we currently construct a 
+FileNotFoundException with a message equal to the filename or assembly 
+name of the assembly that could not be loaded.
+
+To reproduce, compile and run the following code snippet:
+
+using System;
+using System.IO;
+using System.Reflection;
+
+public class Test {
+  static void Main () {
+    try {
+      Assembly.LoadFrom ("b.dll");
+    } catch (FileNotFoundException ex) {
+      Console.WriteLine ("*** #1 ***");
+      Console.WriteLine ("Message: " + ex.Message);
+      Console.WriteLine ("FileName: " + ex.FileName);
+    }
+
+    try {
+      Assembly.Load ("whatever");
+    } catch (FileNotFoundException ex) {
+      Console.WriteLine ("*** #2 ***");
+      Console.WriteLine ("Message: " + ex.Message);
+      Console.WriteLine ("FileName: " + ex.FileName);
+    }
+
+    try {
+      AppDomain.CurrentDomain.ExecuteAssembly ("c.dll");
+    } catch (FileNotFoundException ex) {
+      Console.WriteLine ("*** #3 ***");
+      Console.WriteLine ("Message: " + ex.Message);
+      Console.WriteLine ("FileName: " + ex.FileName);
+    }
+  }
+}
+
+Actual result:
+
+*** #1 ***
+Message: b.dll
+FileName: b.dll
+*** #2 ***
+Message: whatever
+FileName: whatever
+*** #3 ***
+Message: c.dll
+FileName: c.dll
+
+Expected result:
+
+*** #1 ***
+Message: Could not load file or assembly 'b.dll' or one of its 
+dependencies. The system cannot find the file specified.
+FileName: b.dll
+*** #2 ***
+Message: Could not load file or assembly 'whatever' or one of its 
+dependencies. The system cannot find the file specified.
+FileName: whatever
+*** #3 ***
+Message: Could not load file or assembly 'c.dll' or one of its 
+dependencies. The system cannot find the file specified.
+FileName: c.dll
+
+Note: 
+
+without this fix, the ToString () of the FileNotFoundException for these 
+load errors would just be the name of the file (or the assembly name), 
+which doesn't tell very much (unless you know that it concerns a 
+FileNotFoundException).


More information about the mono-bugs mailing list