LP on .NET

August 2, 2011

.NET Fusion Log Viewer 101

Filed under: .NET,C# — Larry Parker @ 9:15 pm

The .NET Framework provides a utility called the Assembly Binding Log Viewer (Fuslogvw.exe) that lets you configure the CLR to log and view assembly binding and probing information for your .NET apps.  This can be very helpful in tracking down why assemblies cannot be loaded (e.g. you’ve got the wrong version installed, a version from the GAC is loading unexpectedly, etc.).

You can run Fuslogvw.exe by opening up a Visual Studio command prompt and typing “fuslogvw”, or by running it from the Microsoft Windows SDK Tools menu under the Visual Studio 2010 program group.

Here’s a screenshot of the Fusion Log Viewer’s main screen:

image

To set things up, click the Settings button and fill out the Log Settings dialog box accordingly.  For example:

image

Once you’ve enabled logging, the CLR will start sending assembly binding information to the output directory whenever you run a .NET application.  Fusion’s logging output is created in folders for each app you run, and separate HTML files are created for each assembly.  For example:

image

You can view the contents of each HTML file by double-clicking them from Windows Explorer, or by selecting them in the Fusion Log Viewer and clicking the View Log button (or double-clicking the grid row).

Note that you might need to click the Refresh button to see any data.

image

Each HTML file shows detailed information about the CLR’s success (or failure) in attempting to load an assembly:

image

Important Tip

All this assembly binding logging is useful, but don’t forget to turn it off!  The CLR will continue to log information even after you exit the Fusion Log Viewer!  I actually left it on without realizing it, and one day found over 18,000 HTML files in the output directory!

So make sure you disable logging in the Log Settings dialog when you no longer need it:

image

Well those are the basics of this useful (although potentially verbose) utility.  For more information, see MSDN here, as well as an excellent blog post on the subject here.

Hope this helps.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

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

Create a free website or blog at WordPress.com.

%d bloggers like this: