简体   繁体   English

添加引用Project vs DLL

[英]Adding reference Project vs DLL

I have few projects in a solution. 我在解决方案中的项目很少。 When adding reference we have two ways - 添加参考时我们有两种方式 -

  1. Add project as reference 添加项目作为参考
  2. Add DLL directly reference 直接添加DLL引用

Which should be preferred ? 哪个应该是首选?

If you add a project reference the dll you use will be updated automatically if you edit project files. 如果添加项目引用,则在编辑项目文件时,将自动更新您使用的dll。

You add DLL directly when you are not working on DLL sources. 您不在DLL源上时直接添加DLL。

You should use the DLL reference if the dll itself isn't meant to change, like external assemblies, or selected stable releases of other projects (ie not not necessarily the most recent build). 如果dll本身不打算更改,则应使用DLL引用,如外部程序集或其他项目的选定稳定版本(即不一定是最新版本)。

You should use a project reference if you always want to use the latest build of the referenced project (and if you want to debug the referenced project). 如果您总是希望使用引用项目的最新版本(并且如果要调试引用的项目),则应使用项目引用。

Add it as a project reference. 将其添加为项目引用。 This will ensure you have the correct dll when you build your solution, Debug or Release. 这将确保您在构建解决方案,调试或发布时拥有正确的dll。

Otherwise you would have to depend on a location of your dll and that would be either debug or release and perhaps not even the most recent one. 否则你将不得不依赖于你的dll的位置,这将是调试或释放,甚至可能不是最新的。

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

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