Bugzilla – Bug 322364
[PATCH] Improve exception reported for invalid IL images
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by gert.driesen@pandora.be 2006-10-14 10:05:27 MST ---- The attached patches contain exception improvements for both runtime and corlib when an invalid IL image is loaded. Runtime: * appdomain.c: Use mono_get_exception_bad_image_format2 to construct BadImageFormatException in ves_icall_System_Reflection_Assembly_LoadFrom when fname does not refer to valid assembly. This result in a more meaningful error message. * exception.c: added mono_get_exception_bad_image_format2 which constructs a BadImageFormatException using the ctor taking a custom message and the file name. Passing in a NULL msg results in a default message. * exception.h: define mono_get_exception_bad_image_format2 function. * icall.c: in InternalGetAssemblyName, throw BadImageFormatException when file name pointed to an invalid IL image. Use mono_get_exception_file_not_found2 to construct FileNotFoundException, as this results in a more meaningful error message. Corlib: * BadImageFormatException.cs: Changed message for default ctor to match MS. Use internal message field of Exception to check whether Message is null. Match MS default messages when no message is set. Fixed ToString to match MS. * AssemblyName.cs: No need to convert filename to absolute path before passing it to Assembly.InternalGetAssemblyName. This allows our exception messages to be better match those of MS. * BadImageFormatExceptionTest.cs: Added ctors tests. * corlib_test.dll.sources: Added BadImageFormatExceptionTest.cs. Let me know if it's ok commit. ---- Additional Comments From gert.driesen@pandora.be 2006-10-14 10:05:58 MST ---- Created an attachment (id=170649) Runtime changes ---- Additional Comments From gert.driesen@pandora.be 2006-10-14 10:06:23 MST ---- Created an attachment (id=170650) Corlib changes ---- Additional Comments From miguel@ximian.com 2006-10-15 11:07:06 MST ---- This is OK to commit ---- Additional Comments From gert.driesen@pandora.be 2006-10-15 11:23:47 MST ---- Fixed in svn. Imported an attachment (id=170649) Imported an attachment (id=170650)