14
votes

Is there any way of removing unused references to assemblies, in a C# project, without the help of Resharper? The MSDN documentation does outline something for Visual Basic, but I couldn't find the same dialogs for C#.

2
Is your question about removing references to assembles that are not necessary or about removing using statements in each source file that are not necessary?Martin Liversage
Removing unused references to assemblies, yes.Rohit

2 Answers

9
votes

There is no build in support in Visual Studio to find unused assembly references in a C# project.

A workaround is, to remove a possible unused assembly, compile the project and look if it compiles successfully. If it´s the case an unused assembly was removed. Otherwise the removed assembly was necessary and it should be added again.

To check what assemblies are used by other assemblies you can use NDepend.

1
votes

For individual .cs code files, VS 2008 has: Edit, IntelliSense, Organize Usings, Remove Unused Usings (Alt-E, Alt-I, Alt-O, Alt-R). I haven't spotted anything for Projects.