0

Not at all like this thread How do I add assembly references in Visual Studio Code? Someone has given me 2 dlls, I need to add(reference ) them in my project, I am writing a plugin of sorts. It's my first C# project since I stopped programming about 4 years ago.

dotnet add reference {path to my first dll}

Just produces a message that tells me I am on the wrong track completely. I have the using statements, which require the 2 assemblies, but Visual studio code commands are a little opaque to me still.

2
  • The question is asking about visual studio code, not visual studio. Commented Feb 27, 2020 at 21:27
  • Does this answer your question? Commented Feb 27, 2020 at 21:32

2 Answers 2

2

You can add a reference to a dll by directly editing the csproj file. Within an ItemGroup (preferably the ItemGroup containing your other references) you can add a Reference property. It should look like the following:

<ItemGroup>
   ...
   <Reference Include="<dll name>">
      <HintPath></HintPath> //Relative Path to dll from csproj directory
   </Reference>
   ...
</ItemGroup>
Sign up to request clarification or add additional context in comments.

1 Comment

So the VSCode console commands was the wrong track, and I just needed pointers on how to edit the project manually , thanks Gustavo.
1

1) For an easy and fast way to add DLL's you can drag and drop them into your solution Reference folder then rebuild your project.

2) The second way, you can right-click on the Reference folder in your VS solution and (add reference) then rebuild your project.

1 Comment

The question is asking about visual studio code, not visual studio.