简体   繁体   English

最终编译程序集中.Net中项目和dll依赖项之间的差异

[英]Difference between project and dll dependencies in .Net in the final compiled assembly

Lets say I have two projects A and B. A depends on B. I can specify this in two ways: 假设我有两个项目A和B. A取决于B.我可以用两种方式指定:

  • Include A and B in the same solution and specify B as a project dependency for A. This shows up in A's msbuild project as a "ProjectReference" node. 在同一个解决方案中包含A和B,并将B指定为A的项目依赖项。这在A的msbuild项目中显示为“ProjectReference”节点。
  • Include a reference to the B's compiled dll as dependency for A. This shows up in A's msbuild project as a "Reference" node 包含对B的已编译dll的引用作为A的依赖项。这在A的msbuild项目中显示为“Reference”节点

My question is, once I've build the assembly for A, is there a difference in the final output between these two methods. 我的问题是,一旦我为A构建程序集,这两种方法之间的最终输出是否存在差异。

I tried creating a couple of simple projects which model this relation and tried a comparison - but different comparison tools are telling me different things. 我尝试创建几个简单的项目来模拟这种关系并尝试比较 - 但不同的比较工具告诉我不同​​的东西。 Pending writing something which compares these files byte-by-byte, I was wondering if you folks knew anything about this. 在写一些逐字节比较这些文件的东西时,我想知道你们是否对此有所了解。 Specifically, will there be any difference in the behaviour of the built assembly if I use dll reference instead of a project reference. 具体来说,如果我使用dll引用而不是项目引用,构建的程序集的行为是否会有任何差异。

If the project B sources have not changed in between two builds of project A, there will be no difference in the behavior of the project A output. 如果项目B源在项目A的两个版本之间没有变化,则项目A输出的行为将没有差异。 However, if project B sources have changed, referencing it as a project from project A will cause project B to be rebuilt as well. 但是,如果项目B源已更改,则将其作为项目A中的项目引用也将导致项目B重建。 This difference is what determines your choice of how to reference project B from project A: 这种差异决定了您如何从项目A中引用项目B:

  • if you own the source of both project B and project A, and they are tightly coupled, or if they both are under active development and project B undergoes often breaking changes of its public interface, you want to reference project B as project. 如果您拥有项目B和项目A的源,并且它们紧密耦合,或者如果它们都处于活动开发状态并且项目B经常断开其公共接口的更改,则您希望将项目B作为项目引用。 This would ensure that project A always uses in its build the most up-to-date output of project B. 这将确保项目A始终在其构建中使用项目B的最新输出。

  • if project B is external dependency you don't develop yourself, or you don't have the sources to, or if it has been shipped already and you can't ship modified version with project A, you want to reference the pre-built project B output, to ensure you are developing and testing with the same version of project B, that is most likely to be on your users' computers. 如果项目B是外部依赖项,您不自行开发,或者您没有源代码,或者如果它已经已经发货且您无法运送带有项目A的修改版本,则需要参考预先构建的项目B输出,以确保您使用相同版本的项目B进行开发和测试,这很可能是在用户的计算机上。

Adding as project reference just has the advantage that assembly "B" is automatically built if required. 添加为项目参考只是具有如果需要则自动构建组件“B”的优点。

Once assembly "A" is built, there is no difference. 组装“A”后,没有区别。

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

相关问题 在项目中查找程序集依赖项 - Finding assembly dependencies in a project 在安装项目中,添加“项目输出”和“程序集”之间的区别 - In Setup project, difference between adding 'project output' and 'assembly' .Net项目的程序集依存关系 - Assembly dependencies with .Net projects .NET程序集依赖项 - .NET Assembly Dependencies .Net Reactor 错误:无法更新项目的依赖项。 无法确定 object 'PHMateLib.DLL' 的依赖关系 - .Net Reactor ERROR: Unable to update the dependencies of the project. The dependencies for the object 'PHMateLib.DLL' cannot be determined 无法加载文件或程序集'quickfix_net.dll'或其依赖项之一 - could not load file or assembly 'quickfix_net.dll' or one of its dependencies 无法在ASP.NET网站中加载文件或程序集“ Jedox.Palo.Comm.DLL”或其依赖项之一 - Could not load file or assembly 'Jedox.Palo.Comm.DLL' or one of its dependencies in ASP.NET Website 无法加载文件或程序集“Magick.NET-x86.DLL”或其依赖项之一 - Could not load file or assembly 'Magick.NET-x86.DLL' or one of its dependencies C#.NET中程序集,模块和包之间的区别 - Difference between an Assembly, Module and Package in C#.NET .NET方法(.dll)和反映版本之间的性能差异 - Performance difference between .NET method (in .dll) and reflected version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM