UWP app for Xbox: System.Drawing is not supported on this platform? Really?

Gary Scharf 1 Reputation point

This was not listed as one of the missing APIs for XBOX, and so I'm wondering what's up, and which API I should use in its place.

Context: I'm generating a QRCode using QRCoder to display.

From the logs:

Exception thrown: 'System.PlatformNotSupportedException' in System.Drawing.Common.dll
An exception of type 'System.PlatformNotSupportedException' occurred in System.Drawing.Common.dll but was not handled in user code
System.Drawing is not supported on this platform.

The code:

Bitmap bmp;

        using (var ms = new MemoryStream(qrCode.GetGraphic(20)))
            bmp = new Bitmap(ms);     <==== Exception thrown here
Universal Windows Platform (UWP)
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,237 Reputation points Microsoft Employee

    Please use libraries with UWP support, such as https://github.com/codebude/QRCoder

    System.Drawing depends on GDI+, which is an ancient Windows graphic API, so it is not available in UWP or other platforms.

    0 comments No comments

  2. daniel@musketeer-ss.com 1 Reputation point

    I came across this same issue with Blazor Mobile Bindings.

    Solution: Use the PCL version of QRCoder, such as BitmapByteQRCode-Renderer.

    0 comments No comments