3

I'm trying to convert a Base64String back to an Image. I have this code set up in my C# console application.

public Image Base64ToImage(string base64String) { // Convert Base64 String to byte[] byte[] imageBytes = Convert.FromBase64String(base64String); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Image ms.Write(imageBytes, 0, imageBytes.Length); Image image = Image.FromStream(ms, true); return image; } 

I'm getting an error each time I use the type Image. It says:

The type or namespace name could not be found.

I'm using:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Threading.Tasks; using System.Net.Mime; using System.Drawing; 

Am I missing a library?

2 Answers 2

6

Yes, if you're writing a console application, your project probably won't include a reference to System.Drawing.dll, which is the assembly containing System.Drawing.Image. Just add the assembly reference, and it should be fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks ya'll...7 whole more minutes until I can accept an answer. Damn.
1

In the project window, right click on the references, and choose "Add Reference..." In the .NET Framework, choose System.Drawing.dll.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.