如何将程序集添加到 Visual Studio 项目并引用它?
我已经编译了 MySql.Data.dll
的程序集,并希望将其添加到新的 Visual Studio 项目中。我不知道正确的术语以及如何最好地解决这个问题,但最终目标是分发此 dll,以便在应用程序运行时将其包含在应用程序中。这是为了避免必须在最终用户的计算机上 GAC dll。
我尝试简单地将程序集复制到项目文件夹中:
但是,我不知道如何添加当前项目中对该 dll 的引用。我也没有弄清楚如何确保该 dll 在编译后将“留在”应用程序中。如何实现这一点以及我还可以考虑哪些其他事情?
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:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试以下操作
添加后,单击“引用”文件夹下的引用并按 F4。这将打开属性工具窗口。确保将其设置为“复制本地”= True。这将确保它通过标准安装程序(MSI 和 ClickOnce)与您的应用程序一起部署
Try the following
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)
右键单击“引用”并选择“添加引用...”,导航至 DLL,然后...就完成了。
Right-click on References and select Add Reference..., navigate to the to DLL and presto ... you're done.
右键单击参考文献->添加参考->永远等待列表加载 ->浏览->选择您的 Dll
,然后将其添加到引用列表中,将其设置为“复制本地”(如果尚未设置)。这会将其放入输出文件夹中。
Right Click References -> Add Reference -> Wait forever for the list to load -> Browse -> Select your Dll
Then when it has been added to the reference list, set it to Copy Local (if it is not already). This will put it in the output folders for you.
右键单击列表中的“引用”文件夹,然后选择“添加引用”。在“浏览”选项卡上,浏览到包含项目的目录及其子文件夹。选择程序集并将其添加到项目中。
Right click on the "References" folder in the list and choose Add reference. On the Browse tab, browse to the directory containing your project, and the subfolder. Select the assembly and add it to the project.
右键单击解决方案资源管理器中的项目,然后选择“添加引用...”。然后您可以浏览到该文件。
Right click on the project in Solution Explorer and select 'Add Reference...'. Then you can browse to the file.