Thursday, 10 May 2007

Using Bind Monitor (FUSLOGVW.exe)

Don't you just hate it when you've done all the development work and you are finally deploying the release onto a server and BANG! It doesn't work, you have some sort of assembly loading exception/file not found exception?

All of us (yes even you) have had assembly binding issues on our server and development machines, but not many of us know about or make use of the Bind Monitor (FUSLOGVW.exe) bundled in the .Net SDK. The tool is useful because depending on the options selected, it can log binds occurring between assemblies - including bind failures and their associated details.

The Bind monitor can be found at \Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\FUSLOGVW.exe so it is useful to add this as an external tool using Tools > External Tools. Now you can access it easily in Visual Studio at Tools > Bind Monitor OR if you are trying to find out the issue on a server machine without the developer environment installed then just copy the file from a development machine (\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\FUSLOGVW.exe) to the server.

Tips for Bind Monitor < V2

Firstly click on Log Failures. Next, if this is an ASP.NET or .NET Windows service app, select the Custom Option and using regedit, set HKLM\Software\Microsoft\Fusion\LogPath to point to a directory that exists (c:\temp\binds\?). To log all binds, not just failures, set HKLM\Software\Microsoft\Fusion\ForceLog as a DWORD value to 1.

Tips for Bind Monitor V2

You can sometimes get an issue when not using Enable custom log path (the default locations is the internet explorer Temporary Files cache). So I usually turn that on and point it at a log/temp directory.

To log bind failures for satellite assemblies, you need to do a little fix by adding a HKLM\Software\Microsoft\Fusion\LogResourceBinds registry value to 1 (the value is a DWORD) - this also seems to fix some other problems, so I strongly recommend it.

More Info?

The MSDN page for the Bind Monitor can be found here Bind Monitor - FUSLOGVW.exe.

Fusion is the technology used for loading assemblies in .Net and there is a great site with a Fusion Workshop covering all aspects of the technology.

There is a great wiki page on .NET Assemblies which is useful for anyone that has some queries on assembly basics and is too scared to ask?!