2

I'm having a weird problem. I'm using Visual Studio 2012 Express for Windows Phone 8 and want to refer System.Drawing.dll. I right-clicked "reference" in the project and clicked "Add reference...", however, I cannot find System.Drawing.dll under .NET tab. Any ideas why?

Actually I want to convert my image to base64. I have one method and this method contains Sysytem.drawing imaging .dll.

public string imagetobase64(image image,
  system.drawing.imaging.imageformat format)
{
    using (memorystream ms = new memorystream())
    {
        // convert image to byte[]
        image.save(ms, format);
        byte[] imagebytes = ms.toarray();

        // convert byte[] to base64 string
        string base64string = convert.tobase64string(imagebytes);
        return base64string;
    }
}

Convert image to base64 string. How can I solve this problem?

İsmet Alkan
  • 5,361
  • 3
  • 41
  • 64
Mansinh
  • 1,365
  • 4
  • 19
  • 47

1 Answers1

5

(Answered before the question was changed to actually ask two questions...)

Any ideas why?

Yes - you simply can't use System.Drawing.dll in Windows Phone 8.

Look at the list of supported .NET namespaces in Windows Phone 8 - System.Drawing isn't there, and all the public types in System.Drawing.dll are in the System.Drawing namespace (or one starting with System.Drawing, anyway).

You haven't said what you're actually trying to achieve, but you'll just have to find some other way of doing it.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • :Thanks for replay and see my edited Question.if you have any solution than give me – Mansinh Apr 29 '13 at 06:19
  • 1
    @MansinhDodiya: That's now completely changed the question. I suggest you rollback to the previous form, and then ask a *new* question about how you can save an image in WP8. Also bear in mind that C# is case-sensitive - the code you've posted wouldn't work even if System.Drawing *were* supported. – Jon Skeet Apr 29 '13 at 06:22
  • :thanks i am tring solve my problem if you have any idea than give otherwise no problem and again thanks – Mansinh Apr 29 '13 at 06:26