Getting exception System.PlatformNotSupportedException' in System.Drawing.Common.dll

I am getting the PlatformNotSupportedException for System.Drawing.Common.dll when I manually add the reference to the Aspose.PDF.dll and System.Drawing.Common.dll. tried the runtime config switch but it is still not working. but it seems to be able to work properly if I install the package using nuget, without even configuring the runtime config switch. the DLLs I used when I manually reference it was taken from the nuget folder.

i am using .net6 framework.

version for the dll is as follows:
Aspose.PDF.dll: 22.10.0
System.Drawing.Common.dll: 6.0.0

@bczm8703

We already logged an issue to test Aspose.PDF functionality under .NET 6.0 in non-Windows environments as PDFNET-50918. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Could you please share the operating system name that you are using along with complete stack trace of exception?

@tahir.manzoor

sorry forget to mention that this is a console app running in window system

@bczm8703

Please share the complete stack trace of exception. Thanks for your cooperation.

System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
   at System.Drawing.Drawing2D.Matrix..ctor(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy)
   at #=zUiy7JEdQZBs_SLAyZYNrxMb$kI_b3vMthQ==.#=z$5afqcbiqDC660pfNCpcpc8=(SizeF #=zps_a4gQ=)
   at #=zUiy7JEdQZBs_SLAyZYNrxMb$kI_b3vMthQ==.#=zfW56YAE=(SizeF #=zps_a4gQ=)
   at #=z5pD0d8artnvUU6GMJVUFltp88BZ7VDFbfg==.Render(#=zynboLqNzCM_llWRX7LICfP2z9Lgf #=z13gOXjw=)
   at #=zGlWdb9Wf66Q8wLXabknLzq0d6_qa8B_T3w==.#=zLdJ4lOwjimc7(#=zhXMLh$SCUKppGMK4JdFljIU= #=z_Arn6cirlxYrMNcBBg==, #=zgwaYuE8uWcsTlCtILbC1muXRJ$hb[] #=zrm3_FwXdLsh6, #=zynboLqNzCM_llWRX7LICfP2z9Lgf #=z13gOXjw=, TimeSpan #=znDlGZQA=)
   at #=z$isEXGWhCjEu_XcZQ0rn_bIO_c5C.Render(#=zynboLqNzCM_llWRX7LICfP2z9Lgf #=z13gOXjw=, TimeSpan #=znDlGZQA=, #=zSxs6j$stng3KcRbWE_m2xoU=[] #=zebNBRaM=, #=zN_B0JjRG$kib0Pkx9HSsBcY=[] #=zbUoDYoU=)
   at #=z$isEXGWhCjEu_XcZQ0rn_bIO_c5C.Render(#=zynboLqNzCM_llWRX7LICfP2z9Lgf #=z13gOXjw=, TimeSpan #=znDlGZQA=, #=zN_B0JjRG$kib0Pkx9HSsBcY=[] #=zbUoDYoU=)
   at #=z2DagbrldHhvTlY_acnUmXkK$d4oo.Render(#=zynboLqNzCM_llWRX7LICfP2z9Lgf #=z13gOXjw=, #=zwlzlRrg= #=zXGVj7e4=, TimeSpan #=znDlGZQA=)
   at #=z2DagbrldHhvTlY_acnUmXkK$d4oo.Render(#=zynboLqNzCM_llWRX7LICfP2z9Lgf #=z13gOXjw=, #=zwlzlRrg= #=zXGVj7e4=)
   at #=zGZuXg_SHwiPf$cVilzu3asxqaKoG.#=z8$XX3BXHVyiU(Stream #=zc3oFa7mE5NMQ, Document #=z1FgEjegUa$Of, HtmlLoadOptions #=zI3aNHjFEP45$, String #=z23Z1nAoaBVND)
   at #=zGZuXg_SHwiPf$cVilzu3asxqaKoG.#=zhFICfMo=(Stream #=zc3oFa7mE5NMQ, Document #=z1FgEjegUa$Of, HtmlLoadOptions #=zI3aNHjFEP45$, String #=z23Z1nAoaBVND)
   at #=zGZuXg_SHwiPf$cVilzu3asxqaKoG.#=zhFICfMo=(Stream #=zc3oFa7mE5NMQ, Document #=z1FgEjegUa$Of, HtmlLoadOptions #=zI3aNHjFEP45$)
   at Aspose.Pdf.Document.#=ztB2qyfI=(Stream #=zCIz2PJc=, LoadOptions #=zF0qDUsc=)
   at Aspose.Pdf.Document..ctor(Stream input, LoadOptions options)
   at ConsoleApp.GeneratePDF.Program.GeneratePdf(StringBuilder contentSB) in D:\projects\ConsoleApp\ConsoleApp.GeneratePDF\Program.cs:line 86

@bczm8703

Thanks for sharing the detail. The issue PDFNET-50918 is different from the shared exception.

Please attach the following resources here for testing:

  • Your input PDF document.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi, Attached is my sample app with the Aspose License, Aspose.PDF.dll and System.Drawing.Common.dll being removed

SampleApp.7z (50.7 KB)

@bczm8703

We have not found this issue at our end. Please check the attached image for detail. No Exception.jpg (193.5 KB)

Please remove these DLL files from the application and install Aspose.PDF for .NET 22.10 through NuGet. Hope this helps you.

hi. i am aware that installing the DLL via nuget will fix the issue. i am wondering if I am able to manually reference the DLL without having any issue?

@bczm8703

There is no issue adding reference of Aspose.PDF for .NET manually. Please download Aspose.PDF for .NET installer or DLL version from following links and add reference into your project.
Aspose.PDF for .NET 22.10 (DLLs only)
Aspose.PDF for .NET 22.10

tried downloading via the Aspose.PDF for NET 22.10 (DLLS only) and still getting the same exception

@bczm8703

You are using .NET 6.0 in your application. Please add reference from net6.0 folder. We have tested again the same scenario and have not faced any issue.

@bczm8703

Please install Aspose.PDF for .NET 22.10 through NuGet to avoid this issue. If you want to add reference manually, please get latest version of System.Drawing.Common and add it into your application to avoid this issue.