[英]How to add a .dll reference to a project in Visual Studio
I am just beginning to use the MailSystem.NET library.我刚刚开始使用 MailSystem.NET 库。 However, I cannot figure out where to add the.dll files so I can reference the namespaces in my classes.但是,我不知道在哪里添加 .dll 文件,以便我可以在我的类中引用命名空间。 Can someone please help me?有人可以帮帮我吗? I am using Visual Studio 2010. Thank you for any information, there is so little online.我正在使用 Visual Studio 2010。感谢您提供任何信息,网上的资料太少了。
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 Reference
dialog.将下载的 DLL 文件复制到开发驱动器上的自定义文件夹中,然后使用“ Add Reference
对话框中的“浏览”按钮添加对项目的Add Reference
。
Be sure that the new reference has the Copy Local = True
.确保新引用具有Copy Local = True
。
The Add Reference
dialog could be opened right-clicking on the References item in your project in Solution Explorer可以在解决方案资源管理器中右键单击项目中的引用项打开Add Reference
对话框
UPDATE AFTER SOME YEARS几年后更新
At the present time the best way to resolve all those problems is through the目前,解决所有这些问题的最佳方法是通过
Manage NuGet packages menu command of Visual Studio 2017/2019. Visual Studio 2017/2019 的管理 NuGet 包菜单命令。
You can right click on the References node of your project and select that command.您可以右键单击项目的 References 节点并选择该命令。 From the Browse tab search for the library you want to use in the NuGet repository, click on the item if found and then Install it.从“浏览”选项卡搜索要在 NuGet 存储库中使用的库,单击找到的项目,然后安装它。 (Of course you need to have a package for that DLL and this is not guaranteed to exist) (当然,您需要为该 DLL 提供一个包,但不能保证存在)
For Visual Studio 2019 you may not find Project -> Add Reference option.对于 Visual Studio 2019,您可能找不到 Project -> Add Reference 选项。 Use Project -> Add Project Reference.使用项目 -> 添加项目引用。 Then in dialog window navigate to Browse tab and use Browse to find and attach your dll.然后在对话窗口中导航到“浏览”选项卡并使用“浏览”查找并附加您的 dll。
You probably are looking for AddReference dialog accessible from Project Context Menu (right click..)您可能正在寻找可从项目上下文菜单访问的 AddReference 对话框(右键单击..)
From there you can reference dll's, after which you can reference namespaces that you need in your code.从那里您可以引用dll,之后您可以在代码中引用您需要的命名空间。
Another method is by using the menu within visual studio.另一种方法是使用 Visual Studio 中的菜单。 Project -> Add Reference... I recommend copying the needed .dll to your resource folder, or local project folder. Project -> Add Reference...我建议将所需的 .dll 复制到您的资源文件夹或本地项目文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.