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

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();

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


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;

Perhaps you need to add:

using System.Windows.Media.Imaging;

Need Your Help

Checking if a column exists in an application database in Android

android database sqlite

Is there a nice way in Android to see if a column exists in a table in the application database? (I know there are questions similar to this one already, but there don't seem to be any that are And...

NPM clean modules

node.js npm

Is there a way to get npm to unbuild all the modules under node_modules? Something like npm rebuild that removes all build artifacts but doesn't rebuild them?