Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Bitmap' could not be found (are you missing a using directive or an assembly reference?)

Tags:

c#

bitmap

I am getting the following compile-time error:

The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)

Here is my code:

BitmapImage img = new BitmapImage();
like image 717
sara brown Avatar asked Jul 23 '12 06:07

sara brown


4 Answers

You have to add System.Drawing to your references so in solution Explorer rightclick on References and click on Add References and in assemblies find System.Drawing and click OK

like image 109
LA SN Avatar answered Nov 20 '22 05:11

LA SN


Today (2020 year) it's nuGet package System.Drawing.Common.dll. To add it: right click on project name (at solution explorer) --> "Manage NuGet packages" --> choose "Browse" label at the top --> search for "System.Drawing.Common" --> install it.

like image 30
user1234567 Avatar answered Nov 20 '22 07:11

user1234567


Add PresentationCore as a reference.

How-to:

  1. Click the .NET tab.
  2. Locate and click the PresentationCore item from the list.
  3. Click the OK button.

Result:

The PresentationCore assembly appears in the References list for your project.

Finally:

Add a using directive for the System.Windows.Media.Imaging namespace at the top of the file, which is where BitmapImage lives.

using System;
using System.Windows.Media.Imaging;
like image 6
harini bangalore Avatar answered Nov 20 '22 06:11

harini bangalore


Perhaps you need to add:

using System.Windows.Media.Imaging;
like image 3
Dane Balia Avatar answered Nov 20 '22 07:11

Dane Balia