Monday, 2 August 2010

Enable Fusion Assembly Binding Logging

The WRN: Assembly binding logging is turned off message is annoying but assembly binding logging can be extremely helpful when you need to know how .NET is (or isn't) locating the assemblies you've referenced. The message is annoying because, if you're like me, you never have logging enabled and the registry key cited is a bit unusual:

To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

What does the exclamation mark mean? Presumably EnableLog is a DWORD in the Fusion key but it's all a bit unclear for my liking. Once you've set this DWORD, you need to figure out what to do next and for many people that will likely involve firing up the Fusion Log Viewer fuslogvw.exe or the Windows/.NET SDK. But then what?

Gary Kindel was kind enough to post the following details in response to a related Stack Overflow question:

Add the following values to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion

DWORD ForceLog set value to 1
DWORD LogFailures set value to 1
DWORD LogResourceBinds set value to 1
String LogPath set value to folder for logs ie) C:\FusionLog\

Make sure you include the backslash after the folder name. I also found an IISRESET was necessary in a web context.

Since I wanted to enable this logging in an environment without Visual Studio or the Windows SDK installed, the above option was clean and lightweight. Log files were dumped to the expected location in .html format and it was then a case of locating the assembly I was interested in… and, oh yeah, fixing the problem ;-) The issue was also detailed in the ASP.NET error message returned by IIS.

Advanced geeks: because Fusion logging supposedly affects performance, you might want to create a reg file/batch script to toggle logging on and off. Here's a starting point—put this into a file called EnableFusionLogging.reg and double-click to run it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"ForceLog"=dword:00000001
"LogFailures"=dword:00000001
"LogResourceBinds"=dword:00000001
"LogPath"="C:\\Temp\\FusionLog\\"

I actually call this from a batch script which also resets IIS and I have a mirror reg file that disables logging.

If you found this post helpful, please support my advertisers:

5 comments:

  1. You can just open the Assembly Binding Log Viewer, which comes with Visual Studio, as administrator and change the settings. No need for changing the register.

    ReplyDelete
  2. sorry i might be slow but i still dont get what i put in the log path space:(

    ReplyDelete
  3. @Anonymous #1: the above steps describe a situation where Visual Studio isn't installed.

    @Anonymous #2: the LogPath simply indicates the directory where you want log file dumped.

    ReplyDelete
  4. just installed framework 3.5 and solved the issue..

    Thanks

    Vinod

    ReplyDelete
  5. I had to enable this loggind, which showed me exactly what path is called.
    I just copy and pasted the needed OracleDataacess.dll from my oracle bin folder to the destinations the webapp was looking for it and this solved the issue.
    Missing file:Oracle.DataAccess.dll
    Destination 1
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\NameOfApp\e29df288blabla\702293blabla\Oracle.DataAccess>
    Destination2:
    d:\Pathofwebroot\pathofwebapp\bin\

    I then reverted the registry setting back to avoid the performance penalty.
    thanks for saving my day!

    ReplyDelete

Spam comments will be deleted

Note: only a member of this blog may post a comment.