Aspose.BarCode is not working in Xamarin

Hi,

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,
Willem.

[1]

Support added on version 18.6

[2]
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

[3]
=== 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 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000125

=== Mono Framework MDK ===

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

=== Roslyn (Language Service) ===

3.9.0-6.21152.10+c10f884b30737542ddd84ca889a4aad9281ce210

=== NuGet ===

Version: 5.8.0.6860

=== Xamarin Designer ===

Version: 16.9.0.324
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:
5.0.202
5.0.201
5.0.103
5.0.100
3.1.408
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core 3.1 SDK ===

SDK: 3.1.408

=== Apple Developer Tools ===

Xcode 12.4 (17801)
Build 12D4e

=== Xamarin.Mac ===

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

=== Xamarin.iOS ===

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

=== Xamarin.Android ===

Version: 11.2.2.1 (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

@wtoerien,
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?
NuGet Gallery | System.Drawing.Common 7.0.0

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.

System.Drawing.Common/Stubs.cs:22
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap…ctor(System.IO.Stream)

@wtoerien,
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.

Blockquote Problem could be solved with replacing System.Drawing.Common to Aspose.Drawing for .NET when it will be ready.

Is there any possibility that you can tell me when it will be ready?

@wtoerien,
Well, as this is quite a huge task, it is not possible to share any ETA yet. We will write back here once any update is ready for sharing.

1 Like