Analyzing and Display Assembly References for Visual Studio Solutions

I extended my application VS Solution Dependency Visualizer to extract, analyze, and display assemblies referenced by all projects contained in a Visual Studio solution.

Depending on the options selected to analyze a .sln file, assembly reference information is displayed for a project or for the whole solution if selected in the solution tree.

The assembly references will also be included in the generated .png and .dia diagrams showing project and assembly dependencies:

The latest release (version 0.40) of VS Solution Dependency Viewer is available for download here.

Displaying Project Dependencies and Solution Folder Dependencies

While I was writing the introductory blog to VS Solution Dependency Visualizer, I already had a lot of ideas about what functionality could be included in the future.

Displaying Project Dependencies

I do not know of an easy way to find which projects in a Visual Studio solution reference a specific project.

Upon analysis of a solution, VS Solution Dependency Visualizer will now display all references of a project once it is selected in the project tree:

Displaying Solution Folder Dependencies

Solution folders can be used to group projects into function groups or architectural layers. To make sure the dependencies are correct between layers and groups, generate a Solution Folders Dependency chart

The latest release of VS Solution Dependency Viewer is available for download here.

Visual Studio Solution Dependency Visualizer

The result of my evaluation of project dependency visualizers was that while some of the tested applications worked on some solutions, none of them could handle all my test cases. Moreover, the generated graphs were simply too large to be useful.

On the other hand, my application dbscript already contains a graph module to generate data diagrams, which could be re-used for displaying project dependencies.

Time to write my own 😉

My new application, VS Solution Dependency Visualizer, analyzes C# project dependencies within a Visual Studio solution file, and is tested to work on any VS version from 2003 to 2010.

It is a stand-alone .Net application, but can also be invoked from the context menu of a .sln file.

In a hierarchical view of solution folders and projects, developers select the projects to be analyzed:

After analysis, simply generate a .png file, or a .dia chart, and the default viewer for the generated file opens automatically.

See some screenshots and output samples in the product’s gallery.

The initial release of VS Solution Dependency Viewer is available for download here.

Comparison of Visual Studio Project Dependency Visualizers

If you work in a Visual Studio solution that contains lots of projects (in my case, about 90), you occasionally need to check your project dependencies: in a multi-layered architecture, a project may only reference projects of certain layers, but not of others.

A quick search gave me 3 tools that visualize VS solution dependencies

All of them make use of the GraphViz library, so their output looks similar.

I tested with a couple of .sln files dating back from VS2003 up to the current VS2010. These solution files are from C# software projects that I created or that I was working on, so your experience may be different.

depcharter

After installation depcharter, which also includes GraphViz, depcharter can be added to the context menu of .sln files by adding a .reg file to the registry.

However, I never accomplished to generate a chart using depcharter. It crashes on web site projects, and otherwise ends with the messages “No dependencies, nothing to do” or “Error generation diagram”.

DependencyViewer

DependencyViewer is a WPF application that opens a selected solution file, allows the user to select/deselect the projects to be included in the chart, and select an output filename. After generating the graph, the resulting .png file is automatically opened in the default viewer.

DependencyViewer crashes on some solution (my guess is either web site projects and/or spaces in paths), but successfully generates png charts:

Dependency Visualizer

Dependency Visualizer installs itself as context menu on .sln files, and provides a separate configuration application to adjust some settings, such as inclusion of referenced assemblies and .Net libraries in the chart.

Upon right-click, Visualize Dependencies, it generates a .png and a .svg chart in a newly created Dependencies subdirectory of the solution’s directory.

Unfortunately it only supports Visual Studio 2005 and 2008 solution files.

Conclusion

Not all visualizers support all kinds of projects in solution files. (Disclaimer: any program error or crash may be caused by my handling of the applications)

Generally speaking, charts generated GraphViz are quite huge: they range from 500  pixels wide for simple solutions (10 projects), up to 12.000 pixels wide for a solution containing 90 projects.