Bug 322364 (MONO79661) - [PATCH] Improve exception reported for invalid IL images
Summary: [PATCH] Improve exception reported for invalid IL images
Status: RESOLVED FIXED
Alias: MONO79661
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: 1.1
Hardware: Other All
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-14 17:05 UTC by Gert Driesen
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Runtime changes (3.19 KB, patch)
2006-10-14 17:05 UTC, Thomas Wiest
Details | Diff
Corlib changes (18.37 KB, patch)
2006-10-14 17:06 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:12:56 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)