What is fusion
Fusion is the module in .net which manages binding of .net assemblies. So the question here is why do we need to setup fusion logs. Since we know that fusion is module which is responsible for assembly bindings, its good to know that it also emits verbose logs known as fusion logs. These log entries lists out the activities that fusion does for loading an Assembly. The logs will also show us why a particular Assembly failed to load: this is why most folks enable fusion logger.
Fusion logging is not turned on by default. We’ll have to turn it on via registry entry or use fuslogvw.exe to set verbosity of fusion logging: for e.g. what needs to be logged, bind failures?
The fusion module comes into play during Assembly binding phase. We can request binding via automatic references in project or via explicit code requests etc.
What is an Assembly
An Assembly in .net is made of the following components…
In short Assembly is made up of a manifest file (the main module) and can also have other module files as well. The manifest metadata will have references to the other modules that an Assembly has.
How to enable fusion logging
Please follow these steps to enable fusion logging.
1. Run Visual studio 2010 command prompt as admin.
2. Run fusion log tool: fuslogvw.exe. Fuslogvw should be there in your SDK folder, in my case…
C:Program FilesMicrosoft SDKsWindowsv6.0ABinFUSLogvw.exe. You can as well run it directly from your Visual Studio command prompt.
If fusion log viewer is not installed on your machine, then add the registry entries given below manually and check out the log folder for output.
3. Open the settings dialog as shown in above image by clicking on the “Settings” button.
4. Enable “Log all binds to disk”.
5. Check “Enable custom log path”.
a. Enter a custom fusion log path, in my case I used “C:FusionLog”.
6. Say “Ok”.
7. Go ahead with execution of your application. If you restart/refresh the log viewer you should see log entries as shown in the above screenshot.
Following registry entries get added to the registry when you enable options via above settings dialog of fuslogvw.exe. Just in case if you don’t have fuslogvw.exe installed on your box add the relevant one manually into the registry or you can create a .reg file which does this consistently.
- Log all binds to disk
- HKEY_LOCAL_MACHINESOFTWAREMicrosoftFusionForceLog = 1
- Log bind failures to disk
- HKEY_LOCAL_MACHINESOFTWAREMicrosoftFusionLogFailures = 1
- Log in exception text
- HKEY_LOCAL_MACHINESOFTWAREMicrosoftFusionEnableLog = 1
- Log Disabled
- No entry.
- Enable custom log path
- HKEY_LOCAL_MACHINESOFTWAREMicrosoftFusionLogPath = c:fusionlog
Viewing logs in the fusion folder
Click on any of the log entries in the above log viewer, entries are saved to disk in html format, the corresponding html file will open in your default browser. You can also view the entries directly by opening the log folder contents directly, in my case c:fusionlog.
The last line mostly says whether the assembly loaded successfully or not. The lines before that will tell why the loading failed. Instead of “Log:” you’ll see something like “WRN:”/”ERR:” etc.
Fusion log viewing is the best way to figure out Assembly load issue.