How to reference assemblies using Visual Studio Code?
Asked Answered
H

3

32

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.

Hypogastrium answered 8/8, 2015 at 0:9 Comment(6)
GDI and GDI+ are not available on OS X.Yt
so is there anything similar I can use?Hypogastrium
Add from menu : Project : Add Reference : Net Tab : System.DrawingNichollenicholls
@Peter, System.Drawing, Mono.CairoCultivable
@Nichollenicholls there isn't a project menu in 'Visual Studio Code'Hypogastrium
Please refer to kolim's solution posted at #42001298Chad
C
14

The new .NET Core SDK restore command is dotnet restore

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

Chad answered 22/2, 2017 at 22:0 Comment(1)
I am not able to add System.Web.Script to use JavaScriptSerializer.Afton
T
17

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.

Tentacle answered 17/12, 2015 at 0:58 Comment(4)
This answer is no longer correct since project.json isn't used in more recent versions of .NET Core (moved to .csproj project file format.)Errantry
Thanks @PerLundberg I updated my answer to reflect this.Tentacle
How about referencing to a wsdl web service? Can I add the address to. Csproject and restore project?Suspire
@AProgrammer I'm not familiar with WSDL, but nuget restore/dotnet restore is only for nuget packages as far as I know.Tentacle
C
14

The new .NET Core SDK restore command is dotnet restore

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

Chad answered 22/2, 2017 at 22:0 Comment(1)
I am not able to add System.Web.Script to use JavaScriptSerializer.Afton
D
0

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

Doodlebug answered 8/8, 2015 at 1:28 Comment(1)
the question isn't really about how to add System.Drawing specifically. It is asking how can I add a reference to ANY assembly using Visual Studio Code.Hypogastrium

© 2022 - 2024 — McMap. All rights reserved.