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?
views:
87answers:
4If 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)
Looks like Resharper is it. However I wouldn't worry too much about it as the unused assemblies are ignored by the compiler.
Reflector to the rescue again!
- File > Open > Your assembly
- Right-click the assembly in the left pane and select Analyze
- 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.
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.