
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
386
|
Chapter 7: Exception Handling
catch (Exception e) // Note that you would use one catch block or the other,
{ // not both.
// This displays the exception information along
// with any fusion log information.
Console.WriteLine(e.ToString( ));
}
}
Discussion
Use this technique to debug problems when loading an assembly from a file. When
using the ToString method of the Exception object, notice the bottom part of the
error message that starts with “Fusion log follows.” This is the section that can pro-
vide some clue as to why the reflection APIs could not find your assembly. If you
want just the fusion information, you can use the
FusionLog property of one of the
aforementioned exception objects. The Assembly Binding Log Viewer (fuslogvw.exe)
is another place where the load failure information can be retrieved. In order for this
log to be filled, the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Fusion|ForceLog and LogFailures entries should be specified as type
DWORD with a
value of 1 for each entry. Without these entries, the log will not record failure infor-
mation, and it will only be available from the
FusionLog property.
See Also
See the “BadImageFormatException Class,” “FileLoadException Class,” and “File-
NotFoundException Class” topics in the MSDN documentation.
7.8 Mapping Back and ...