Error setting font style .net standard

We upgraded aspose.barcode to version 23.12 and we set BarcodeGenerator

.Parameters.Barcode.CodeTextParameters.Font.Style = Aspose.Drawing.FontStyle.Bold

On runtime we are getting the attached error ( method not found fontunit.set_style(aspose.drawing.fontstyle)), this seems to happen on project using .net standard 2.0.

@deveregroup,

I did test your scenario/case with latest Aspose.BarCode for .NET v23.12 using .NET6.0 project, it works fine and the output image (attached) is fine tuned. Here is the sample code that I am using:
e.g.
Sample code:

Aspose.BarCode.Generation.BarcodeGenerator gen = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.EAN13, "1234567890128");
gen.Parameters.Barcode.CodeTextParameters.Font.Style = Aspose.Drawing.FontStyle.Bold;
gen.Save("g:\\test2\\Ean13.png", Aspose.BarCode.Generation.BarCodeImageFormat.Png);

Ean13.png (951 Bytes)

The issue does not occur on .net 6, it occurs when the barcode generator code is on a .net standard project and is accessed from a .netframework site. Attached is a sample test site were I managed to replicate the issue.

@deveregroup,

Thanks for the sample project and further details.

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

Issue ID(s): BARCODENET-38877

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

As I see you have the following line in \TestSite\TestSite.csproj

<Reference Include="Aspose.BarCode, Version=23.12.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
  <HintPath>..\packages\Aspose.BarCode.23.12.0\lib\net47\Aspose.BarCode.dll</HintPath>
</Reference>

And you have TargetFramework v4.7.2.

Aspose.BarCode for all of .NETFramework versions uses System.Drawing instead of Aspose.Drawing.Common. Because, at this time, .NETFramework fully correctly works only on Windows and System.Drawing works well on Windows you can use:

.Parameters.Barcode.CodeTextParameters.Font.Style = System.Drawing.FontStyle.Bold;

Also yo can use the following construction to avoid setting namespace name

#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER
using Aspose.Drawing;
#else
using System.Drawing;
#endif
.Parameters.Barcode.CodeTextParameters.Font.Style = FontStyle.Bold;

Hi, thanks for the explaination, the problem is that on compilation it is expecting aspose.drawing since it is in a .net standard, even if at runtime it is running using .net framework. I even tried the code you supplied and it still does not work> attached the project with the updated code

@deveregroup,

Thanks for the sample project and feedback.

We will evaluate your issue using your sample project and get back to you with updates.

Aspose.BarCode net47 uses System.Drawing. All of Aspose.BarCode .NETFramework versions use System.Drawing.

Aspose.Drawing is used only by .NETStandard 2.0 (netstandard2.0 folder), .NETStandard 2.1 (netstandard2.1 folder), net5.0, net6.0, net7.0 versions.

And we a working on article which can describe how to link Aspose.Drawing .NETStandard 2.0 library to .net 4.7.2 project in case of using Aspose.Drawing.

You can download .NET Dependency Walker, open lib\net47\Aspose.BarCode.dll and you can see the following dependencies

system_drawing_depenedency.png (49.1 KB)

I have updated your project:
TestSite_Updated.zip (30.5 KB)

The main updates were to packages.config and TestSite.csproj. Because compiler does not know what version of the libraries you want to use you have to set required frameworks manually.

Some later we brought out the article in our documentation. At this time you can learn project example.