Free Support Forum -

Aspose.BarCode is not working in Xamarin


We are currently looking into Aspose.BarCode and are trying to get it working in our Xamarin project. We read that Aspose.BarCode does support Xamarin[1]. Unfortunately, we get a PlatformNotSupportedException[2] the moment we initiate the BarCodeReader. I have also added the version numbers we are running on[3].

Can you please advise?

Kind Regards,


Support added on version 18.6

image.jpg (309.9 KB)

Stack Trace:
at System.Drawing.Image…ctor () [0x00006] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/Facades/System.Drawing.Common/Stubs.cs:688
at System.Drawing.Bitmap…ctor (System.IO.Stream stream) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/Facades/System.Drawing.Common/Stubs.cs:22
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap…ctor(System.IO.Stream)
at Aspose.BarCode.BarCodeRecognition.BarCodeReader.SetBarCodeImage (System.IO.Stream stream) [0x0002d] in :0
at Aspose.BarCode.BarCodeRecognition.BarCodeReader…ctor (System.IO.Stream stream, Aspose.BarCode.BarCodeRecognition.BaseDecodeType type) [0x0002f] in :0
at OUTsurance.Mobile.Features.BarcodeScanner.AsposeBarcodeReader.Read

=== Visual Studio Community 2019 for Mac ===

Version 8.9.8 (build 7)
Installation UUID: 01fd6342-d3b2-44ac-af79-e923fd74e4a0
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac (d16-6 / 088c73638)

Package version: 612000125

=== Mono Framework MDK ===

Mono (2020-02/8c552e98bd6) (64-bit)
Package version: 612000125

=== Roslyn (Language Service) ===


=== NuGet ===


=== Xamarin Designer ===

Hash: b1e216c75
Branch: remotes/origin/d16-9
Build date: 2021-04-16 00:02:50 UTC

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.202/Sdks
SDK Versions:
MSBuild SDKs: /Applications/Visual

=== .NET Core 3.1 SDK ===

SDK: 3.1.408

=== Apple Developer Tools ===

Xcode 12.4 (17801)
Build 12D4e

=== Xamarin.Mac ===

Version: (Visual Studio Community)
Hash: ab40b131d
Branch: xcode12.5
Build date: 2021-04-22 08:56:41-0400

=== Xamarin.iOS ===

Version: (Visual Studio Community)
Hash: ab40b131d
Branch: xcode12.5
Build date: 2021-04-22 08:56:42-0400

=== Xamarin.Android ===

Version: (Visual Studio Community)
Commit: xamarin-android/d16-9/877f572
Android SDK: /Users/ivankruger/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 31.0.1
SDK Build Tools Version: 30.0.2

Build Information:
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@54f8c24
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.34.1@daff8f4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@d210f11

We have observed the issue while initializing the BarCodeReader class object and logged an issue in our database for further investigation. You will be notified here once any update is ready for sharing. For our reference, please share your simplified complete solution containing Aspose.BarCode related code only for testing here.

This issue is logged as:
BARCODENET-37816 - Error while initializing BarCodeReader class object in Xamarin based application

1 Like

Thank you for the response.

An interesting thing is that when I put the code in the iOS/Android Xamarin project rather than the shared project, it shows that the System.Drawing.Common Dll’s are incompatible.

Do you use dll from netstandard 2.0 folder and have System.Drawing.Common 5.0+ installed?

Do you use dll from netstandard 2.0 folder and have System.Drawing.Common 5.0+ installed?

Yeah, that is the code that I listed above. When we have the reading logic in the shared project, it compiles, but upon running the code, we get the PlatformNotSupportedException. When we have the reading logic in the Android/iOS specific projects, we then see the compilation errors. In spite of having the System.Drawing.Common lib 5.0+ installed, if you look at the stacktrace, you’ll see that it is still trying to reference the mono stubs.

at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap…ctor(System.IO.Stream)

We have noted your feedback and will analyze it while working on this issue.

I quickly investigated your problem (a lot of work at this time so your task is planned on next week) and found that System.Drawing.Common is not supported in Xamarin.Android/iOS

I found other question about System.Drawing.Common and there is the same information

18.6 version used SkiaSharp as image processing engine but current versions use System.Drawing.Common with definite issues on non Windows systems.

So I think problem is System.Drawing.Common with Xamarin on Android and iOS.

And on this file System.Drawing.Bitmap is marked as not supported.

In version 19.8 SkiaSharp was replaced by System.Drawing.Common which is used as image library for Aspose.Barcode for .Net.

Xamarin uses Mono instead of .Net Core and System.Drawing.Common is not implemented. It has 4.0 version and not implemented functions stubs. Because Aspose.Barcode for .Net uses System.Drawing.Common, it is impossible to use Aspose.Barcode with Xamarin.

Problem could be solved with replacing System.Drawing.Common to Aspose.Drawing for .NET when it will be ready. Until this, the problem could not be fixed.