System.Drawing in customBarcodeGenerator throwing PlatformNotSupported Exception in Ubuntu

Hi Team,
We are trying to generate a PDF from a word template which has a Barcode in it. In a Linux-Ubuntu environment we are seeing this error but in windows environment it works. Below is the error that we are seeing in Ubuntu

“Type”: “System.PlatformNotSupportedException”, “ExceptionMessage”: “System.Drawing.Common is not supported on this platform.”, “StackTrace”:" at System.Drawing.Font…ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit)\n at \b.(Int32 , Int32 )\n at .(Int32 , Int32 , Int32 )\n at .( , AutoSizeMode , Int32 )\n at .( )\n at e.(BaseGenerationParameters )\n at e.()\n at Aspose.BarCode.Generation.BarcodeGenerator.GenerateBarCodeImage()\n at Rsi.Correspondence.Infrastructure.CustomBarcodeGenerator.GetBarcodeImage(BarcodeParameters

It looks like the error is been thrown from the BarCode Generetor class. Is this expected for .NET 6.0 and any workaround for this?

Alternatively, you can enable support for non-Windows platforms in .NET 6 by setting…

hi @alexander.gavriluk,

I have tried the workaround of setting the runtime config property in the above link but still i see same error.
In the same link i also see the below.
To use these APIs for cross-platform apps, migrate to one of the following libraries:

Is there any plan Aspose remove dependency on the System.Drawing and use one of the above librabries.

Any other workarounds that you suggest.

@tharunchennuri,

With the release Aspose.BarCode for .NET 23.2 (see the Release notes document), System.Drawing.Common in Aspose.Barcode for .NET (.NET Core) is replaced with Aspose.Drawing.Common. So, could you try it if it works for your needs. Please note, the version has not been published on Nuget repos. yet. Moreover, you may also manually download the Aspose.Drawing.Common library.

@amjad.sahi,

I have downloaded the above said Aspose.BarCode for .NET 23.2 and when i tried generating the document in the run time first i got the error that System.Text.Encoding.CodePages is not found so added it. Next got error Aspose.Drawing not found so added it.

Now i am seeing the error like below.

TypeLoadException: Could not load type ‘Aspose.Drawing.Bitmap’ from assembly ‘Aspose.Drawing, Version=23.2.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’.

I tried checking for Bitmap Nuget/dll but couldnt get any. Could you please help me with how to get this resolved?

@tharunchennuri,

We are sorry that it still did not work for your scenario/case. We will look into it and get back to you soon.

We have:

  • Aspose.Drawing.Bitmap from Aspose.Drawing.Common
  • System.Drawing.Bitmap from Aspose.Drawing.

Currently classic Aspose.Drawing uses System.Drawing namespace and conflicts with System.Drawing.Common (or any libraries which use it).

You need to use Aspose.Drawing.Common

<ItemGroup>
	<PackageReference Include="Aspose.Drawing.Common" Version="23.2.0" />
	<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>

@alexander.gavriluk,

It worked!! Thanks a lot.

We have license of Aspose.Barcode and Aspose.Word. But as part the above implementation we had to add Aspose.Drawing.Common Nuget to get it working. So do we need to get the licenese for Aspose.Drawing.Common as well?

Also when is it expected to get the new Aspose.Barcode package as part of Nuget?

Aspose.Drawing is set automatically in case of any Aspose.Barcode function call.

@alexander.gavriluk,

Sorry to ask again. But this means that we don’t need any additional licenses at all.
Please confirm.

Thanks.

Yes, main idea that if you have any license of Aspose product which uses Aspose.Drawing.Common you do not need additional license for Aspose.Drawing.Common. But you can buy standalone Aspose.Drawing.Common license if you do not need any other Aspose product.

Aspose.Drawing.Common will be our graphic hub for all of Aspose.Barcode libraries. It already works well on Linux systems and we are working on adding support for .Net MAUI on Android and iOS.

PS
And yes, currently we have some problems with publishing Aspose.Barcode on nuget.