Dependency Graph in Visual Studio 2010 – View Assembly Dependencies

Posted by: Suprotim Agarwal , on 11/27/2010, in Category Visual Studio
Views: 61597
Abstract: In this article, we will see how to explore a .NET assembly using the Dependency Graph Tool in Visual Studio 2010 Ultimate.

The Visual Studio 2010 Ultimate Edition has some excellent Architecture tools for modeling new applications, as well as analyze an existing application. One tool amongst them is the ‘Dependency Graph’.

As quoted in MSDN, Dependency graphs help you learn more about the organization and relationships in existing code. So let us say that you have just joined a new project and the application has no documentation (yes we have all been there!) or you need to move your project from an older version to a newer one and want to use a tool to make sure that there are no references during the upgradation or you simple want to explore an assembly inside out - the Dependency Graph can be very useful in all these scenarios.

In this article, we will start by seeing how to explore an existing .NET assembly using the Dependency Graph tool. In future articles, we will see how to generate dependency graphs for projects, like an ASP.NET project. We will be using the System.Web.Routing.dll for this example. You can find this assembly on your machine if you have .NET 3.5 SP1 or .NET 4.0 installed. Alternatively, you can choose any other assembly of your choice.

Let us get started:

Step 1: Open Visual Studio 2010 > Architecture > New Diagram

Visual Studio New Diagram 

Step 2: Choose ‘Directed Graph Document’ from the list of Diagrams and click OK as shown below:

Directed Graph Document 

Note: If a Modeling project does not exist, you will be prompted to create one. Give it the name ‘WebRoutingModeling’ and click OK.

You should now see a screen similar to the following:

UML Model Explorer 

Step 3: Now drag and drop the System.WebRouting.dll or any other .dll or exe of your choice from your Windows Explorer, to the empty area. If you chose the System.WebRouting.dll, you should see a screen similar to the following:

Dependency Graph 

Step 4: You can choose to go as detailed as possible! Right click the System.Web.Routing.dll node > View Content

Note: The graph shows only those dependencies for code that builds successfully!

View Content Dependency Graph 

You will see an Assembly Dependency screenshot similar to the one shown below. Notice the colored Legend to the right, which helps you understand the different components of your dependency graph.

Assembly Dependency 

You can drill down into the System.Web.Routing.dll node by clicking on the V-Shaped arrow (a.k.a. Chevrons) as indicated by the red arrow, in the screenshot shown above.

Note: At any point, you can hover your mouse over the arrows connecting each node, and get additional details by clicking the center plus button as shown below:

Assembly Dependency Two 

Clicking the center ‘+’ button, brings up the different members to include in the Dependency Graph. I have selected to see all the options (Assembly, Namespaces, Types and Methods) as shown below:

Generate Dependency Options

Step 5: Click on the V-shaped arrow again to see the different Namespaces in this assembly.

Dependency Graph Classes 

Clicking on the V-shaped arrow (as shown above) on the System.Web.Routing namespace, brings up the different Classes, Enums and Interfaces in this Namespace

Dependency Graph Class Layout 

Note: Do you observe a number to the left of each node. When you see this number on a namespace, it represents the classes, interfaces and enums in each class (System.Web.Routing had 24). Similarly when you see this number on a Class, it represents the number of methods in the class.

Click on the V-shaped arrow on the class to view the methods in the class.


Isn’t this a very useful tool? In this article I have just scratched the surface of what this tool can do. For a person who has just joined a project (especially a Legacy app), this tool can be of immense use to understand the layout of the application or validate the design with the implementation.

One drawback I see is that this tool comes with Visual Studio Ultimate 2010, which is beyond the reach of many developers due to its cost, unless you were lucky and I gave you one for Free ;).

If you want a Dependency Visualizer tool for Visual Studio 2005/ 2008, check the Free DependencyVisualizer from Codeplex. Alternatively if you have a small budget, NDepend is a good alternative too!

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigious Microsoft MVP award for ten consecutive times. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that offers Digital Marketing and Branding services to businesses, both in a start-up and enterprise environment.

Get in touch with him on Twitter @suprotimagarwal or at LinkedIn

Page copy protected against web site content infringement 	by Copyscape

Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by Lajapathy on Tuesday, April 17, 2012 1:21 AM
Super article






jQuery CookBook