Tuesday, October 25, 2011

Fusion log viewer fuslogvw ie Assembly Binding Log Viewer

When you work with .net and your dlls are scattered around GAC, application bin, or reference assemblies its very difficult to check which version of dll is loaded in the application. Without knowing that you cannot ensure that your code changes are in effect. For small projects you can put Console.WriteLine or Messagebox.Show to indicate your code change .But when we talk about bigger applications with hundreds of project and thousands of code files ,it is not practical.Also there are chances that your message box code might get checked into the code repository which gives fun for others.

Another scenario is creating and maintaining AppDomains .There are concepts like ApplicationBasePath, PrivateBinPath for the appdomains which decides from where the runtime should load the assembly or what is the sequence in searching for assembly. If you are versioning your application there are chances for MissingMethodException if the loaded assembly is not compatible with the versions.

All these things says we need to profile/inspect the assembly loading behavior in .net on the fly to make sure the dlls are loaded from correct location and it is the Fusion log viewer which comes with Visual Studio.

Starting the tool
  • Make sure the registry entry HKLM\Software\Microsoft\Fusion\ForceLog is 1
  • Goto visual studio command prompt.
  • Type and enter 'fuslogvw'
  • This will bring you the tool window.Make sure the log path is correct.
  • Now run your assembly.
  • Once the application loads click on the refresh button in the assembly log viewer.
  • You got the details of assemblies loaded with loading history and from which location
This is very useful in my current project to identify assembly loading where we have versioning and play with AppDomains all around.

No comments: