I'm having trouble getting the Bitmap class to work properly in my C# project. Despite extensive searching, the common advice I find is to "Add reference to System.Drawing", which I have tried to do (I think).
Here's what I've done so far:
However, the solutions I found online suggest using Add reference, but in my Visual Studio, I only see options for Add Project Reference, Add COM Reference, and Add Shared Project Reference.
Here is the code I'm working with:
using System;
using System.Drawing;
static void Main(string[] args)
{
Bitmap myBit = new Bitmap("url"); // ERROR
}
I'm getting the following error:
CS1069: The type name 'Bitmap' could not be found in the namespace 'System.Drawing'
Visual Studio Version: Visual Studio 2019 version 16.11.36
How can I correctly reference the System.Drawing namespace and use the Bitmap class?
I've added the reference via Project -> Add COM reference -> Browse and then select "Sytem.drawing.visualstudio.dll"
You shouldn't be adding a COM
reference and that's not the correct library to add. See below to add the correct reference to use the System.Drawing
namespace that has Bitmap
class.
References
under your project.Add Reference
.Assemblies
.Search
-> system.draw
etc...System.Drawing
(mine was 4.0.0.0) make sure it's checked.OK
.You should now see under References
under your project the namespace.