Project (unused) References are removed by the compiler.

Have you ever wondered what happens when you add that extra DLL as reference to your project and never use it? Or maybe, you did use it in the past but now you deleted the code and forgot to remove the DLL for some reason.

The good news is that the compiler takes care of that and outputs just the DLL’s that are in use. Take a look at the following example:

  • I have a console application that has no extra references. And as you can see in the architecture explorer, only mscorelib is used.



  • Now I’m adding an extra reference to a “Third Party”’ DLL, but I’m not using it on code. The compiler still ignores it and only reference (again) mscorelib.



  • Finally, I am using that “Third Party” DLL and the compiler reference it as well.


So rest assure about your extra reference, of course it’s not always “architectural wise” to keep them or easing the eye to view them, but in the end, they are removed by the compiler.