简体   繁体   English

如何在 Visual Studio 中添加对项目的 a.dll 引用

[英]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 提供一个包,但不能保证存在)

Read about NuGet here在此处阅读有关 NuGet 的信息

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.

相关问题 如何在 Visual Studio Code 中添加 DLL 参考 - How to add DLL reference in Visual Studio Code 无法添加python.dll作为Visual Studio项目的引用 - Can not add python.dll as reference to Visual Studio project 在 Visual Studio 中添加对 C++ 项目的新 DLL 引用 - Add new DLL reference to C++ project inside Visual Studio 如何在我的 C# Visual Studio 项目中添加 VC++ DLL 作为参考? - How can I add a VC++ DLL as a reference in my C# Visual Studio project? 如何添加affdex-native.dll作为对Visual Studio 2015的引用? - How to add affdex-native.dll as a reference to Visual Studio 2015? 如何正确地将dll文件添加到Visual Studio的引用中? - How to add a dll file into reference of Visual Studio properly? 如何在没有 Visual Studio 的 CLI 项目中添加.dll 文件? - How to add .dll file in CLI project without visual studio? Visual Studio 2010中的参考项目与参考DLL - Reference Project vs Reference DLL in Visual Studio 2010 无法将Microsoft.Online.Administration.Automation.PSModule dll的引用添加到Visual Studio 2010中的项目中 - Unable to add the reference of the Microsoft.Online.Administration.Automation.PSModule dll to my project in Visual Studio 2010 Visual Studio中的Azure函数 - 如何添加对另一个项目的引用 - Azure Functions in Visual Studio - How to add reference to another project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM