Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a dll file to a C# project

It's a beginners question, but...

Image of dll reference and dll included in project file http://a3.vox.com/6a00c2251e5b66549d00e398ca81eb0003-pi

If you look at the image above, there is the "Bass.Net" dll added as reference and also directly as file in the project.

Can someone tell me what's the point of doing that?

like image 444
Mat Avatar asked Jun 22 '09 21:06

Mat


People also ask

What is .DLL file in C?

In Windows, a dynamic-link library (DLL) is a kind of executable file that acts as a shared library of functions and resources. Dynamic linking is an operating system capability. It enables an executable to call functions or use resources stored in a separate file.

Where do I put DLL files?

Dll files are located in C:\Windows\System32. Do run the full scan of Defender or third party antivirus if you have.


2 Answers

No reason, really. It could be that Visual Studio is set to display files not in the project (hard to tell from the picture) and the dll's happen to be in the main directory. The text is pretty clear that the extra files are

  • bass.dll
  • bassenc.dll
  • lame.exe

The .net one happens to be with the others in the same directory and you need to add it as a reference.

like image 76
Otávio Décio Avatar answered Sep 23 '22 01:09

Otávio Décio


Within Windows, a DLL is a dynamic link library, which packages a set of programmatic functionality together. In this example, bass.dll exposes the features and functionality relevant to audio processing through this file (and any files it depends on). In order to use this functionality, you need the reference in the solution, so that Visual Studio can link it at compile time. The DLL will then typically be copied to your output directory when the application is built.

That's all that is necessary to get the code to work properly, the rest is really just preference or convention. Some people prefer to have all the files that exist in the project directory in the solution, so that the Solution Explorer reflects the file system. Typically you will want to have libraries your application depends on somewhere in your solution directory hierarchy so that the entire application is packaged together (making source code control use easier, for instance). You won't want to put this library in the BIN directory or any directory that Visual Studio generates, though, to avoid accidental deletions. In any event, having the reference is the important part, the file being in the project or solution is not necessary.

Typically, you'll want to keep external libraries out of your source directories, though, so I wouldn't actually recommend this structure. I tend to use a structure like this, but, again, this is all preference:

  • Source: Source code and project files
  • Libraries: DLLs
  • Support: Miscellaneous code or projects, but not actually part of the application (perhaps deployment scripts)
like image 26
krohrbaugh Avatar answered Sep 26 '22 01:09

krohrbaugh