Published articles on other web sites*

Published articles on other web sites*

Visual Studio: Remove Unused References and Assemblies from your Project

When you create a default project in Visual Studio, there are a couple of references and assemblies that get added by default. Just create any new Window, Web, Console or Silverlight project using Visual Studio and check the using directives (only in C# templates) as well as the assemblies that get added.
Visual Studio Usings
You may not need them all. So after you have finished coding, it’s a good idea to remove unused
references as well as assemblies from your project to improve code readability, maintainability as well as gain a slight advantage in the applications load time. If you are using a C# code template (VS 2008 and 2010), you can do the following:
Right-click in your Code behind file > Organize Usings > Remove Unused Usings
Remove Unused Usings
You will find that all unnecessary using directives have been removed. Internally Visual Studio scans through the code and determines the using statements that are necessary for the code to compile. It then removes all other Using statements not needed by the project. After clicking on the ‘Remove Unused Usings’ in the image shown above, here’s what’s left
Remove Unused Usings
Similarly if you are using a VB template, you can use the References Property page to remove unused references from the project. To do so, right click the VB project > Properties or use shortcut Alt+Enter. Select the ‘References’ tab and click on the ‘Unused References’ button.
Unused References
Clicking the button queries the project to determine the references that are not used by the project
Remove Unused References
Click on the Remove button to remove the references not needed.
Note: If you are wondering why is the Remove Unused Assembly feature in a VB template and not in a C# template, read this Bug on MS Connect. Till this gets fixed, NDepend could prove useful,

1 comment:

  1. Take a look at Reference Assistant VS2010 extension by Lardite group. It is completely free but it still works very well!


Related Posts Plugin for WordPress, Blogger...