c# - DLL 引用之间的区别?和用途?

标签 c# c++ asp.net dll dll-reference

请任何人解释一下。这个问题有助于理解常见的事情

问题:

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'?

我在谷歌上找到了答案

回答:

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. 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.

但是:

我不知道从一个项目复制粘贴到另一个项目的过程是什么,有什么区别?

最佳答案

当您将粘贴从一个项目复制到另一个项目时,相关项目会添加其对您在项目解决方案目录中粘贴的文件的引用

当您复制粘贴一个项目的 dll 到另一个项目的目录,然后通过浏览到您粘贴 dll 的目录添加它的引用。然后 VS 仅添加其引用并将该 dll 复制到其 bin 文件夹并向您显示(允许您)它包含的所有方法和属性。

如果您对源项目解决方案进行了任何更改,例如添加或修改方法,则该项目的更新后的 dll 在您的依赖项目解决方案中不可用。

所以 VS 仍然指向旧的 dll 文件只是因为你添加的引用。因此,每当您对源项目解决方案进行任何更改时,每次都必须将更新后的 dll 的引用添加到您的依赖解决方案中。

第二种情况:当您将源项目的引用添加到依赖项目解决方案中时,VS 总是将源项目中最新更新的 dll 提取到依赖项目中。所以这样就不需要在每次编译代码或者调试的时候都添加引用了。

关于c# - DLL 引用之间的区别?和用途?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22217943/

相关文章:

c# - 从文档中返回一行并显示它

c# - 修复 RegEx 以正确捕获括号内的文本

c# - 使用 Excel 数据的简单任务未完成运行导致 "ContextSwitchDeadlock"

c++ - 如何让 GCC 警告标识符名称冲突?

asp.net - 如何获取服务器上唯一的客户端标识符?

c# - System.StackOverflowException ,何时使用 get set 属性?

c++ - Windows 中的 gdb : different behaviour when debugging compiled C and C++ code

c++ - 如何通过在 glm 中导入 h 文件来修复 'duplicate symbol'

c# - 在 ASP.NET Core 2 中排除文件夹

c# - 未找到数据源名称且未指定默认驱动程序