简体   繁体   English

DLL参考之间的区别? 和用途?

[英]Difference Between DLL Reference's? And Uses?

Please any one explain this. 请任何人解释一下。 This Question helps to understand common things 这个问题有助于理解常识

Question: 题:

What is the difference between when you 'add DLL reference from one project to another project via Browse Option and Add DLL reference from Solution project to another project and copy-paste from one project to another project'? 是什么,当你的“添加的区别DLL从一个项目通过浏览选项引用到另一个项目,并添加DLL从解决方案项目引用到另一个项目,从一个项目复制粘贴到另一个项目”?

I have found an answer on google 我在Google上找到了答案

Answer: 回答:

Adding a project reference adds a local project's DLL to the project that references it, and every time the solution compiles, the updated DLL for that project gets copied to the other project. 添加项目引用会将本地项目的DLL添加到引用它的项目,并且每次解决方案编译时,该项目的更新的DLL都会复制到另一个项目。 So when you go through the build process, if you have 5 projects, each one rebuilds its DLL, and copies that DLL to its references. 因此,当您完成构建过程时,如果您有5个项目,则每个项目都会重新构建其DLL,并将该DLL复制到其引用中。

But: 但:

I don't know what the process is and the difference when we copy-paste from one project to another project? 我不知道过程是什么,当我们从一个项目复制粘贴到另一个项目时会有什么区别?

When you do copy paste from One project to another, the dependent project add its reference of the file that you have paste in the project solution directory 当您将粘贴从一个项目复制到另一个项目时,从属项目将其对已粘贴文件的引用添加到项目解决方案目录中

When you do copy paste the dll of one project to the other project's directory and then Add its reference by browsing to that directory where you have pasted your dll. 复制后,将一个项目的dll粘贴到另一个项目的目录中,然后通过浏览到粘贴dll的目录来添加其引用。 Then VS only add its reference and copy that dll to its bin folder and show you (allows you) all the method and properties that it contains. 然后,VS仅添加其引用并将该dll复制到其bin文件夹,并向您显示(允许您)它包含的所有方法和属性。

If you do any change in your source project solution like adding or modifying methods then the updated dll of that project is not available in your dependent project solution. 如果您在源项目解决方案中进行了任何更改(例如添加或修改方法),则该项目的更新的dll在您的从属项目解决方案中不可用。

So VS still points to the old dll file just because of the reference you added. 因此,由于您添加的引用,VS仍然指向旧的dll文件。 So whenever you made any change in your source project solution, you have to add the reference of the updated dll to your dependent solution every time. 因此,无论何时在源项目解决方案中进行任何更改,都必须每次将更新的dll的引用添加到依赖的解决方案中。

In Second Case: When you add reference of your source project into your dependent project solution, VS always take the most recent updated dll from your source project into your dependent project. 第二种情况:将源项目的引用添加到从属项目解决方案中时,VS始终将源项目中的最新更新的dll放入到从属项目中。 So in this way you don't need to add reference every time you compile the code or debug. 因此,通过这种方式,您无需在每次编译代码或调试时都添加引用。

When you just reference a DLL by browsing to it, VS would copy it to the output directory of the dependent project. 当您仅通过浏览来引用DLL时,VS会将其复制到从属项目的输出目录中。

Suppose afterwards that DLL is updated - there is no guaranty that VS would retake that updated DLL, and copy it again to the output directory of the dependent project - which mean, that even after you fixed some bugs in the other project, those bug would persist in the dependent project (because it is still using the previous version of that DLL). 假设此后DLL已更新-VS无法保证将重新获取该更新的DLL,并将其再次复制到从属项目的输出目录中-这意味着,即使在另一个项目中修复了一些错误之后,这些错误也会保留在从属项目中(因为它仍在使用该DLL的早期版本)。

When you add reference to other project in the solution, VS would always take the most recent and updated DLL outputted from that project. 在解决方案中添加对其他项目的引用时,VS将始终采用该项目输出的最新和更新的DLL。

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

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