添加/删除 dll 引用 C#
我正在开发一个桌面应用程序。为此,我正在创建类库。在开发时,我必须多次重建类库以进行功能测试并更新对 DLL 的引用。但是,一旦我添加对 DLL 的引用,然后向类文件添加一些代码并重建它,然后添加对新构建的 DLL 的引用,它就不会更新该引用。它仅指旧的 DLL。
I'm developing a desktop application. For that I'm creating class libraries. At the development time I have to rebuild the class library multiple times for functional testing and update reference to DLL. But once I add a reference to a DLL, then add some code to a class file and rebuild it, and add a reference to the newly built DLL, it's not updating the reference. It refers to the old DLL only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您正在做的事情的预期行为。通过手动添加引用 DLL,您只是复制当时已编译的文件,因此进一步的编译不会更新复制的 DLL。
您想要的是将项目引用添加到工作项目中。
如何:添加对网站中 Visual Studio 项目的引用
That's the expected behavior for what you are doing. By manually adding the reference DLL, you are simply copying the compiled file at that time, so further compiles will not update the copied DLL.
What you want is to add a project reference to the working project.
How to: Add a Reference to a Visual Studio Project in a Web Site
如果您在同一台计算机上进行构建,则当您添加对 DLL 的引用时,它会默认记住该 DLL 的位置,并在出现新版本时选取新版本并构建项目。
有时它可能会感到困惑,因此“全部重建”可以解决问题,或者删除并读取引用。
If you are building on the same machine, when you add a reference to a DLL it will by default remember where that DLL was and pick up newer versions as they appear and the project is built.
Sometimes it can get confused, so a Rebuild All can solve the problem, or dropping and readding the reference.