How do I add an assembly to a Visual Studio projec

2020-02-13 10:43发布

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?

5条回答
时光不老,我们不散
2楼-- · 2020-02-13 11:27

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.

查看更多
放荡不羁爱自由
3楼-- · 2020-02-13 11:27

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.

查看更多
4楼-- · 2020-02-13 11:31

Right click on the project in Solution Explorer and select 'Add Reference...'. Then you can browse to the file.

查看更多
The star\"
5楼-- · 2020-02-13 11:33

Try the following

  • 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

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)

查看更多
家丑人穷心不美
6楼-- · 2020-02-13 11:35

Right-click on References and select Add Reference..., navigate to the to DLL and presto ... you're done.

查看更多
登录 后发表回答