Skip to content

Commit 6c3fd5e

Browse files
authored
Add troubleshooting section for System.Drawing.Common warnings in README (#669)
1 parent 03c57bb commit 6c3fd5e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,27 @@ for (int y = 0; y < size; y++)
174174
}
175175
```
176176

177+
## ⚠️ Troubleshooting
178+
179+
### System.Drawing.Common Warnings (QRCode and ArtQRCode renderers)
180+
181+
The `QRCode` and `ArtQRCode` renderers depend on `System.Drawing.Common`, which Microsoft has [removed cross-platform support for in .NET 6+](https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only). You may encounter one of the following build or runtime errors:
182+
183+
```
184+
CA1416: This call site is reachable on all platforms. 'QRCode.QRCode(QRCodeData)' is only supported on: 'windows'
185+
186+
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
187+
188+
System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
189+
```
190+
191+
Solutions include:
192+
193+
1. Use Windows-specific TFMs such as `<TargetFramework>net8.0-windows</TargetFramework>`
194+
2. Mark methods with the `[SupportedOSPlatform("windows")]` attribute
195+
3. Add platform guards by wrapping code with `#if WINDOWS` or `if (OperatingSystem.IsWindows())`
196+
4. Use cross-platform renderers such as `PngByteQRCode`, `SvgQRCode`, or `BitmapByteQRCode`
197+
177198
## 🚀 CI Builds
178199

179200
The NuGet feed contains only **major/stable** releases. If you want the latest functions and features, you can use the CI builds [via Github packages](https://github.com/Shane32/qrcoder/packages).

0 commit comments

Comments
 (0)