C# 如何在 Visual Studio 中向项目添加 .dll 引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12992286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add a .dll reference to a project in Visual Studio
提问by eatonphil
I am just beginning to use the MailSystem.NET library. However, I cannot figure out where to add the .dll files so I can reference the namespaces in my classes. Can someone please help me? I am using Visual Studio 2010. Thank you for any information, there is so little online.
我刚刚开始使用 MailSystem.NET 库。但是,我不知道在哪里添加 .dll 文件,以便我可以在我的类中引用命名空间。有人可以帮帮我吗?我正在使用 Visual Studio 2010。感谢您提供任何信息,网上很少。
采纳答案by Steve
Copy the downloaded DLL file in a custom folder on your dev drive, then add the reference to your project using the Browse button in the Add Referencedialog.
Be sure that the new reference has the Copy Local = True.
The Add Referencedialog could be opened right-clicking on the References item in your project in Solution Explorer
将下载的 DLL 文件复制到开发驱动器上的自定义文件夹中,然后使用Add Reference对话框中的浏览按钮添加对项目的引用。
确保新引用具有Copy Local = True. 可以在解决方案资源管理器中右键单击项目中的引用项打开
该Add Reference对话框
UPDATE AFTER SOME YEARS
At the present time the best way to resolve all those problems is through the
Manage NuGet packagesmenu command of Visual Studio 2017/2019.
You can right click on the References node of your project and select that command. From the Browsetab search for the library you want to use in the NuGet repository, click on the item if found and then Install it. (Of course you need to have a package for that DLL and this is not guaranteed to exist)
几年后更新
目前,解决所有这些问题的最佳方法是通过Visual Studio 2017/2019的“
管理 NuGet 包”菜单命令。
您可以右键单击项目的 References 节点并选择该命令。从“浏览”选项卡搜索要在 NuGet 存储库中使用的库,单击找到的项目,然后安装它。(当然,您需要为该 DLL 提供一个包,但不能保证存在)
回答by Alexander Taran
You probably are looking for AddReference dialog accessible from Project Context Menu (right click..)
您可能正在寻找可从项目上下文菜单访问的 AddReference 对话框(右键单击..)
From there you can referencedll's, after which you can reference namespaces that you need in your code.
从那里您可以引用dll,之后您可以在代码中引用您需要的命名空间。

