简体   繁体   中英

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. ie 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.

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.

The new .NET Core SDK restore command is dotnet restore

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

Mono提供了您可以利用的WinForms管道实现 ,其中包括对System.Drawing支持。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM