Converting base64string to Image type. Image type could not be found?
base64, c#, image, type-conversion, types
Solution
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.
Problem
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?