ARM64 support for Aspose.BarCode for .NET

Ever since I integrated Aspose.BarCode in my .NET Framework (v4.7.2) WPF application (32bit), my application is crashing with some weird errors. Even DispatcherUnhandledException handler cannot suppress the crash.

My primary target devices are Windows tablets and recent Surface tablets are all ARM64 devices. After extensive research, I have reason to believe that the crash is happening due to Aspose.BarCode not supporting ARM CPUs natively. It seems like Aspose.BarCode for Python via .NET has ARM support. I wonder when will ARM support be added to more mainstream product like Aspose.BarCode for .NET.

Here’s an image from the Event Viewer after the crash.

image.png (79.2 KB)

Searching by the exception code, 0x4000001f, I got this SO article c# - Program and debugger quit without indication of problem - Stack Overflow. The accepted answer mentions x86 emulation subsystem, which surely seems to be the case for me.

According to ntstatus.h file, 0x4000001f (STATUS_WX86_BREAKPOINT) is an exception status code that is used by the Win32 x86 emulation subsystem. It (I suppose) means that you reached a breakpoint which is not exploitable. You should enable debugging unmanaged code.

I would appreciate direct communication with any support personnel to help me resolve the issue.

@suhailmahmood,

Thanks for the screenshot and details.

We need to investigate your issue/requirements in details. We have opened the following new ticket(s) in our internal issue tracking system and will provide updates or deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): BARCODENET-39146

Once we have an update on it, we will let you know here.

1 Like

Officially we support ARM and other architectures, which as supported with .Net Core (.Net), with .NET Standard and .NET Core branches. WPF is outdated technology and it is supported only in .NET Framework branch which is not supported on ARM.

I do not think that adding WPF support for .NET Standard and .NET Core branches would have high priority. In this way you can use own drawing of image generated by Aspose.BarCode .NET Core branch.

You can add Aspose.BarCode .NET Standard to .NET Framework v4.7.2 or use MAUI novel technology instead of WPF.

Thanks for your reply.

WPF is outdated technology and it is supported only in .NET Framework branch which is not supported on ARM.

Are you suggesting that .NET Framework is not supported on ARM at all? But it is! See here. But strangely I could target ARM64 with a .NET Framework 4.7.2 app and it does indeed run on ARM64 device.

You can add Aspose.BarCode .NET Standard to .NET Framework v4.7.2

Are you saying that if I use Aspose.BarCode .NET Standard in my .NET Framework v4.7.2 app, and make an ARM64 build of my app, and then run it on an ARM device, Aspose.BarCode ARM version will be used by my app?

@suhailmahmood,

  1. We were talking about .NET framework v4.7.2. Please note, .NET framework v4.7.2 does not have native support for Arm64; I think this was introduced in .NET Framework 4.8.1.

  2. Apparently, your understanding is correct.

We will evaluate your concerns and findings thoroughly and get back to you with further updates soon.

I followed the article linked in the previous comment about changing from 4.7.2 to .netstandard2.0 for some packages, and now I am getting this error:

image.png (22.5 KB)

thrown from the constructor:

private BarCodeReader CreateAsposeBarCodeReader(Stream stream)
{
    if (_barcodeSetting.RecognizePdf417 && _barcodeSetting.RecognizeQR)
        return new BarCodeReader(stream, DecodeType.Pdf417, DecodeType.QR);

    if (_barcodeSetting.RecognizePdf417)
        return new BarCodeReader(stream, DecodeType.Pdf417);

    if (_barcodeSetting.RecognizeQR)
        return new BarCodeReader(stream, DecodeType.QR);

    return new BarCodeReader(stream);
}

A System.NotImplementedException !?!

@suhailmahmood,

I tested it using VS.NET 2022 with Aspose.BarCode v24.10 and it works fine. Please download/get a standalone sample project using the URL for your reference. Please try to test in your environment if it works fine? If you still find the issue, kindly do create a sample project and share it with us, we will check it soon.

Aspose.Barcode on .NET Framework uses standard System.Drawing as graphic library (which is wrapper around native C++ library) which works tricky on non Windows+x86/x64 platforms. In this way it can … sometimes work.

Aspose.Barcode on .Net Standard/Core platform uses Aspose.Drawing.Common which is fully native .Net library and does not use any native library. But you have to add not only Aspose.Barcode to packages but other libraries like System.Memory, System.Buffers

The System.NotImplementedException was coming from Bitmap constructor. It was resolved after upgrading System.Memory from 4.5.4 to 4.5.5. What a strange way to resolve the issue!

@suhailmahmood,

It appears your problem has been resolved by updating the System.Memory library. Please do not hesitate to contact us again if you have any further questions or comments.

I have been running the app for some time and suddenly I got this error (similar to before). Not sure what else I need to upgrade this time. But it is quite frustrating that I am getting errors from BarCodeResult..ctro (not to mention those strange symbols)

   at Aspose.BarCode.BarCodeRecognition.BarCodeResult.(String )
   at Aspose.BarCode.BarCodeRecognition.BarCodeResult..ctor(e )
   at .()
   at Aspose.BarCode.BarCodeRecognition.BarCodeReader.ReadBarCodes()

@suhailmahmood,

We are sorry that you are getting the issue now. We would appreciate if you could create a sample application (complete source code without compilation errors), zip the project, and provide it to us so that we can reproduce the issue. We will investigate your issue as soon as possible.

Here’s a sample project.

AsposeTest.zip (11.3 KB)

Though it throws a different error than the one I am facing in my real app, but it at one point I was facing this error in my app too, and this was resolved after this change. But in this sample app, even after upgrading System.Memory to 4.5.5 is not resolving the issue.

I tried with all the different constructors (taking Stream, string or Bitmap) and all of them throw the same error.

This is the exception I see from this app at launch.
error

I am working on resolving this issue and if I can resolve it, I will share the code that can reproduce the issue I am facing in my main app.

@suhailmahmood,

Sure, please take your time to provide us the demo project that reproduces the original issue that you are getting in your main app.

Sure. In the meantime can you please run the sample that I shared and tell me what the issue is? It is so simple an app yet it throws error in new BarCodeReader(Stream) line.

@suhailmahmood,

Yes, I did test your sample project. I first updated a few lines in packages.config file as following:

<package id="OpenCvSharp4" version="4.5.3.20211228" targetFramework="netstandard2.0" />
<package id="OpenCvSharp4.runtime.win" version="4.5.3.20211228" targetFramework="netstandard2.0" />
<package id="OpenCvSharp4.WpfExtensions" version="4.5.3.20211228" targetFramework="netstandard2.0" />

I also updated a few lines in the .csproj file as following:

<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<HintPath>..\packages\OpenCvSharp4.4.5.3.20211228\lib\netstandard2.0\OpenCvSharp.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp.WpfExtensions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OpenCvSharp4.WpfExtensions.4.5.3.20211228\lib\netstandard2.0\OpenCvSharp.WpfExtensions.dll</HintPath>
</Reference>

Somehow there was some other System.Memory reference to your project which is an issue (even the library was mentioned Ok in the packages.config and .csproj files). I then removed it manually from the References node in Solution explorer. Now I compile it and run the project and it works fine and I do not get any exception.

1 Like

Can you share the updated version please? I made the same changes as you mentioned, but I am getting build error saying

The type or namespace name 'WpfExtensions' does not exist in the namespace 'OpenCvSharp' (are you missing an assembly reference?)

@suhailmahmood,

Please download/get the working project from the URL for your reference. The shared sample project works fine on my end.

1 Like

Thanks, I got it working too, by just removing the System.Memory from the csproj file (I also removed it from the packages.config, but your version has it btw, but I guess that doesn’t make any difference).

OpenCvSharp adds System.Memory as a dependency, and removing it is also prevented for the same reason. But manually removing System.Memory doesn’t break OpenCvSharp, which is so strange!

@suhailmahmood,

Thanks for your feedback and good to know that it is also working on your side.