79

I am just beginning to use the MailSystem.NET library. However, I cannot figure out where to add the .dll files so I can reference the namespaces in my classes. Can someone please help me? I am using Visual Studio 2010. Thank you for any information, there is so little online.

one noa
  • 345
  • 1
  • 3
  • 10
eatonphil
  • 13,115
  • 27
  • 76
  • 133
  • 1
    Never underestimate open source, the code is the documentation. The author even checked-in the files he got when he upgraded his version of Visual Studio. Not knowing what files matter is a Big Red Flag. You'll need to know the code to fix the bugs. – Hans Passant Oct 20 '12 at 21:28
  • 3
    The question is not really about the code, it's about the build process. And some times, Visual Studio is tricky with us... But you've right to say that he may show us some compiler errors instead of code (or nothing like here). – DestyNova May 29 '15 at 20:40

4 Answers4

87

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.
Be sure that the new reference has the Copy Local = True.
The Add Reference dialog could be opened right-clicking on the References item in your project in Solution Explorer

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.
You can right click on the References node of your project and select that command. 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. (Of course you need to have a package for that DLL and this is not guaranteed to exist)

Read about NuGet here

Steve
  • 213,761
  • 22
  • 232
  • 286
  • 10
    What is the dev drive? – STF May 29 '17 at 08:16
  • 23
    Where is browse button ? – Chutipong Roobklom Jun 08 '17 at 13:32
  • 1
    What "Manage NuGet packages" menu command? Is that on the main menu bar? – wallyk Feb 27 '18 at 22:44
  • It is also on the main manu bar. It is in the PROJECT menu. But it is also on the popup menu that you get when you right click on a project name inside the Solution Explorer window – Steve Feb 28 '18 at 07:53
  • 1
    Hi all, for those still suffering from this issue, for me I just cannot find a browse button in the add reference window, and after googling, was unable to find a project properties window either to enable that button. In the end I just added the reference directly to the .csproj file, it's way easier this way. – Ethan Zhao Nov 18 '21 at 15:04
30

For Visual Studio 2019 you may not find Project -> Add Reference option. Use Project -> Add Project Reference. Then in dialog window navigate to Browse tab and use Browse to find and attach your dll.

Add Project Reference

Click Browse button to access File Explorer

Sergiy Velychko
  • 457
  • 6
  • 6
  • 3
    I can't thank you enough, I started thinking I was dumb for not finding Add Reference – Barnack Dec 10 '20 at 21:47
  • 2
    Definite NO GO. I see 1) A top menu "Project --> Add Reference..." 2) on side of screen, Solution Explorer, myProjectName, References. I can right click and "Add Reference..." there. In either case I get a popup window entitled "Add Reference" with no place to add anything. There is a search box that finds nothing. No way to drag and drop. No way to enter anything of any sort. This is a totally dead popup. No browse tab that I can see. Can you explain? (or better yet provide a screen print in your answer?) Perhaps this is a C# only solution (I'm working in C++)? Many thx. – zipzit Apr 22 '21 at 01:04
  • sure, zipzit , added screenshots – Sergiy Velychko Apr 22 '21 at 06:02
  • @SergiyVelychko, many thx. Your images make this quite clear. When I get to that popup its blank with no way to add information. I have to assume that's because I'm working on C++ console app and not a C# / .NET application. Thx again for taking the time to help confirm that. – zipzit Apr 22 '21 at 06:05
  • 3
    @zipzit And yes, for C++ console project there is no Browse button for me as well. – Sergiy Velychko Apr 22 '21 at 06:13
  • Thanks a lot. Just searched for "Microsoft.Management.Infrastructure" and chose the first one, selected it from the right, and hit the Install button. Worked like a charm. – user258959 Jun 04 '21 at 03:28
  • For those with no browse button and can't find a project properties window to enable the browse button, you can also just add the reference directly to the .csproj file. – Ethan Zhao Nov 18 '21 at 15:14
  • 2
    Is there an update for visual studio 2022? Apparently upon right clicking on References > Add Reference I was greeted with nothing https://i.imgur.com/H4lg860.png – Trung0246 Mar 27 '22 at 10:30
6

You probably are looking for AddReference dialog accessible from Project Context Menu (right click..)

From there you can reference dll's, after which you can reference namespaces that you need in your code.

Alexander Taran
  • 6,655
  • 2
  • 39
  • 60
1

Another method is by using the menu within visual studio. Project -> Add Reference... I recommend copying the needed .dll to your resource folder, or local project folder.

SkiSharp
  • 171
  • 9