Visual Studio Debugging Tips – #2

TL;DR – Find out how your application is locating, resolving and loading your dependencies using FusionLogs and fuslogvw.exe

assembly-point

 

Motivation:

We love black boxes. I don’t mean actual black boxes, but rather software components that provide us with some sort of a service (or output) given a certain input. We usually don’t care how the box does it’s magic, all we care about is that it works. This enables us to write software faster and be much more productive by using existing boxes that were created and tested for us. As we all know, in software we are “Standing on the shoulders of giants”.

Sooner or later there comes a time when one of those boxes does’t work as expected, and that is where lots of developers ‘waste’ precious time on debugging and figuring things out. Understanding the basics and the tooling available for the tools or frameworks that we use allows us to overcome black-box issues fast and become a lot more productive.

Recently i noticed that some developers are sometimes jumping through hoops to find why their program fails when the misbehavior is in some black-boxed component they use in their application. Most of the time it is due lack of knowledge on the basic tooling available for them to debug and resolve issues in those black-boxes.

This post will talk about one black box called ‘Fusion‘ and a pretty neat way of debugging it’s behavior.

 

What is Fusion:

Fusion is a subsystem in .NET that is responsible for locating and loading the Assemblies that your application uses at runtime. After locating the required dependency, Fusion will load that Assembly in to the correct AppDomain to be used by your program.

 

Nuts and Bolts:

When you install Visual Studio, you get a great tool called fuslogvw.exe that allows you to easily trace every issue you have with assembly bindings in your application. You can trace exactly where and how ‘Fusion‘ is looking for and loading your dependencies.

Fusion can log it’s full process of resolving dependencies of your application, versioning issues, probing locations etc… While you can edit a registry key to enable this feature, it is nicer to use fuslogvw.exe.

Just run your Developer Command Prompt that you have on your machine, run the command prompt ‘As Administrator’, and type fuslogvw and press Enter.
devCmd

At this point you should see this simple form on the screen:

fusionform

If you ran the tool as Administrator, you should be able to change the settings of this application. Press ‘Settings’ and a dialog should pop-up.

settings

In order to get a taste of the tool and it’s usage, set your settings as shown in the picture above.
This should start logging all Fusion activities on your disk in the specified location. After running one of your applications, press ‘Refresh’ and you should see new entries in the main window of fuslogvw.

Double-click on any of the entries and check out the logs. The information there is pretty amazing. After browsing through the logs, just think of the next time you get a TypeLoader or Assembly binding issue and you will have to inspect the exact dependency loading process or versioning. This will save you some precious time!

 

Remember:

After using the tool, don’t forget to turn off fusion logging at some point or clear the logs directory once in a while because pretty quickly this directory may grow to a huge size on your disk.

 

Happy debugging,
Shonn Lyga.

 

Visual Studio Debugging Tips – #1
Visual Studio Debugging Tips – #3

About Shonn Lyga

Obsessed with anything and everything in Software Engineering, Technology and Science
This entry was posted in .NET, Debugging and tagged , , , , . Bookmark the permalink.

One Response to Visual Studio Debugging Tips – #2

  1. Pingback: Visual Studio Debugging Tips – #3 | Software Simplified

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s