Visual Studio移除Unsed Reference

本文主要是讲如何清除Visual Studio中没有使用到的“引用”,从而提高应用程序的加载或启动速度。

原文地址:VISUAL STUDIO - WHY SHOULD I REMOVE UNUSED REFERENCES?

参考地址:Lardite Reference Assistant   http://refassistant.codeplex.com/

参考地址:Reference Assistant for Visual Studio 2010

参考地址:Reference Assistant for Visual Studio 11




首先,是作者自己的思考:对于移除未使用的Reference有没有用?

If you regularly write code using Visual Studio as your IDE, you may have a number of libraries and modules referenced in your application. As your application starts to grow and change, you may find that you start to build up quite a few referenced libraries. I've always wondered to myself, does is matter if I have any unused references in my application? Is there any point in removing unused ones, because it doesn't really affect the application....right? Well, it turns out I was wrong.

接着,作者简述:“移除未使用Reference”的好处

By removing any unused references in your application, you are preventing the CLR from loading the unused referenced modules at runtime. Which means that you will reduce the startup time of your application, because it takes time to load each module and avoids having the compiler load metadata that will never be used. You may find that depending on the size of each library, your startup time is noticeably reduced. This isn't to say that your application will be faster once loaded, but it can be pretty handy to know that your startup time might get reduced.

解决方案一:使用Resharper

There are a number of ways to remove unused references in your application. VB.NET developers have long had this option built into Visual Studio, but for us using C#, we have to use extensions. If you use ReSharper, you may have seen the remove unused references feature when you right click on your references in your project.It will simply do the magic for you and remove any unused modules in your project. 

Visual Studio移除Unsed Reference_第1张图片


解决方案二:Reference Assistant for Visual Studio

However, if you aren't a fan of ReSharper, there are still other options. There is a great extension available for Visual Studio that is free and will do practically the same thing as the ReSharper extension. Entitled the Reference Assistant for Visual Studio, you can download the extension from the Visual Studio Gallery. The extension performs multi-criteria analysis of a project and decides which assemblies are useful for a project and removes unused ones. In order to use the extension, simply right click on your references in the project.


Visual Studio移除Unsed Reference_第2张图片

And you will be presented with a dialog of references that you can choose to remove.

Visual Studio移除Unsed Reference_第3张图片


It also has a handy feature that will remove any related 'using' directives after removing the unused references. To edit this option, navigate to the Options tab in Visual Studio and then look for theReferences Assistant section.

Visual Studio移除Unsed Reference_第4张图片


Visual Studio移除Unsed Reference_第5张图片


This simple trick can keep your project neat and efficient! Get started using it today.






你可能感兴趣的:(Visual,Studio)