Matt
Matt

Reputation: 27001

IN VS2008, for C#, How can I figure out which references are needed and which are not?

IN VS2008, for C#, How can I figure out which references are needed and which are not? If you look in the solution explorer for a certain project and expand the references folder, is there a way to tell those that are never called? Will this be determined at compile time and simply not included?

Upvotes: 0

Views: 138

Answers (4)

Edgar Zavala
Edgar Zavala

Reputation: 176

Stephan Brenner created an small tool to do that (http://www.stephan-brenner.com/?p=56) and If you want to create a solution for checking that in code there is an old post in MSDN (http://msdn.microsoft.com/en-us/magazine/cc163641.aspx) which does that. I hope this helps you.

Upvotes: 1

Justin R.
Justin R.

Reputation: 24061

Reflector to the rescue again!

  1. File > Open > Your assembly
  2. Right-click the assembly in the left pane and select Analyze
  3. In the right pane, expand Depends On

This will generate a list of all of the assemblies it depends on, and all of their dependencies, all the way down to the turtles.

Upvotes: 2

Igor Zevaka
Igor Zevaka

Reputation: 76590

Looks like Resharper is it. However I wouldn't worry too much about it as the unused assemblies are ignored by the compiler.

Upvotes: 4

Dean Harding
Dean Harding

Reputation: 72668

If they're not needed, the compiler won't add them to the assembly's manifest so it doesn't really hurt to have them there.

If you want to be obsessive-compulsive about it (like I often am :) then you can just delete one, rebuild and if there's an error add it back. If there's no errors, move on to the next one. The downside to doing that is if you delete a reference that you're not using now but you want to use it later, you have to remember which classes are in which assembly (e.g. if you delete System.Core, then you have to remember that System.Linq stuff is in there if you ever decide to use it later)

Upvotes: 4

Related Questions