Peter
Peter

Reputation: 7804

How to reference assemblies using Visual Studio Code?

I would like to reference the System.Drawing.dll in a console app I am writing using Visual Studio Code on OSX. i.e. I want to use these using statements

using System.Drawing;
using System.Drawing.Imaging;

to avoid this build error

Program.cs(56,20): error CS0246: The type or namespace name `Bitmap' could not be found. Are you missing an assembly reference?

I can't find a tutorial on this, I don't even know if the dll is available in .net core or mono or whatever visual-studio-code uses.

Upvotes: 32

Views: 78376

Answers (3)

ikolim
ikolim

Reputation: 16041

The new .NET Core SDK restore command is dotnet restore

To add any asssembly reference in Visual Studio Code, please refer to my post.

Upvotes: 14

Ahmad
Ahmad

Reputation: 613

In your .csproj file, add your dependency as a PackageReference in an ItemGroup, then run dotnet restore or nuget restore. Example:

<ItemGroup>
  <Reference Include="System" />
  <Reference Include="System.Xml" />
  <Reference Include="System.Core" />
  <Reference Include="Xamarin.iOS" />
  <PackageReference Include="Realm" Version="2.1.0" />
  <PackageReference Include="xunit">
    <Version>2.3.1</Version>
  </PackageReference>
</ItemGroup>

Take a look at this article for a full explanation.

Upvotes: 17

Den
Den

Reputation: 16826

Mono offers a WinForms pipeline implementation that you can leverage, that includes support for System.Drawing.

Upvotes: 0

Related Questions