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.
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
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
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.
Clicking the button queries the project to determine the references that are not used by the project
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,
Tweet
4 comments:
If you are using C#, Muse VSExtension will remove unused references for you
fOr more details visit:
http://visualstudiogallery.msdn.microsoft.com/36a6eb45-a7b1-47c3-9e85-09f0aef6e879/
See this post
http://visualstudiogallery.msdn.microsoft.com/fc504cc6-5808-4da8-ae86-8d3f9ed81606
Very helpfull addin
> See this post
> http://visualstudiogallery.msdn.microsoft.com/fc504cc6-5808-4da8-ae86-8d3f9ed81606
> Very helpfull addin
Thanks a lot! Nice tool!
Nice article. Just wondering any benefit by removing unused references?
Cheers,
Pete
Post a Comment