简体   繁体   English

Visual Studio-建立哪些引用?

[英]Visual Studio - which references are built?

Is there a means of querying a solution or project to query which dll references are actually used in a build? 是否有查询解决方案或项目的方法,以查询在构建中实际使用了哪些dll引用?

I know I can go in and see the references for a project in the "Add Reference" dialogue. 我知道我可以进入“添加引用”对话框中查看项目的引用。 I know that I can look in the BIN folder. 我知道我可以在BIN文件夹中查找。 However, without deleting references and attempting to build, or removing the dlls; 但是,无需删除引用并尝试构建或删除dll; is there a means of querying across the solution or project based on Using directives or something similar? 有没有一种方法可以根据使用指令或类似方法在解决方案或项目中进行查询?

There nothing built in to VS2010 or earlier to perform this cleaning action for C#. VS2010或更早版本没有内置任何东西可以对C#执行此清除操作。 You can open your compiled assembly in ILSpy (free tool) or Resharper (don't remember if it's free) and check the references. 您可以在ILSpy(免费工具)或Resharper(不记得它是否免费)中打开编译的程序集,然后检查引用。 You can safely remove the references from project if they do not appear in ILSpy. 如果引用没有出现在ILSpy中,则可以从项目中安全删除引用。

For each reference, you may find code dependent on this assembly via Resharper. 对于每个参考,您都可以通过Resharper找到依赖于此程序集的代码。 Therefore, if no code is dependent on the reference, you may remove it from project references. 因此,如果没有代码依赖于引用,则可以将其从项目引用中删除。

Although there are certain references which you don't use directly in your code (logger library Elmah is a good example) but they still work for you and you need them. 尽管有些引用您没有直接在代码中使用(记录器库Elmah是一个很好的示例),但是它们仍然对您有用,您需要它们。 Such references must be double-checked. 此类引用必须经过仔细检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM