如何将一个程序集添加到Visual Studio项目并引用它? [英] How do I add an assembly to a Visual Studio project and reference it?

查看:215
本文介绍了如何将一个程序集添加到Visual Studio项目并引用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为 MySql.Data.dll 编译了一个程序集,并将其添加到新的Visual Studio项目中。我失去了正确的术语,并最好地了解这一点,但最终的目标是分发这个DLL,以便在应用程序运行时将其包含在应用程序中。这是为了避免在最终用户的机器上使用GAC。

I've compiled an assembly for MySql.Data.dll and would like to add it to a new Visual Studio Project. I'm lost on the correct terminology and how best to go about this, but the end goal is to distribute this dll so that it's included with the application when the application runs. This is to avoid having to GAC the dll on the end user's machine.

我已经尝试将程序集复制到项目文件夹中:

I've tried simply copying the assembly into the project folder:

但是,我不知道如何在当前项目中添加该dll的引用。我也没有想到如何确保这个DLL在编译后会保持应用程序。

However, I can't figure out how to add a reference to that dll in the current project. Nor have I figured out how to ensure that this dll will "stay with" the application once it is compiled. How might this be accomplished and what other things might I consider?

推荐答案

尝试以下


  • 参考节点右侧的cilck

  • 选择添加参考

  • 点击浏览选项卡

  • 导航到磁盘上的dll MySql.Data.dll,然后点击确定

  • Right cilck on the References Node
  • Choose "Add Reference"
  • Click on the Browse tab
  • Navigate to the dll MySql.Data.dll on disk and hit OK

一次它被添加,点击引用文件夹下的引用,并按F4。这将显示属性工具窗口。确保它设置为Copy Local= True。这将确保由标准安装程序(MSI和ClickOnce)部署您的应用程序

Once it's added, click on the reference under the References folder and hit F4. This will bring up the properties tool window. Make sure it is set to "Copy Local" = True. This will ensure it gets deployed with your application by the standard installers (MSI and ClickOnce)

这篇关于如何将一个程序集添加到Visual Studio项目并引用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆