Exception: PptxReadException on opening presentation in .NET Standard 4.7

We have a Visual Studio solution with 2 projects:

  • ASP Net 4.7.2 console app
  • netstandard 2.0 classlibrary with Aspose.Slides
    (see attachment of sourcecode and Visual Studio Solution)

When we call our netstandard library from the ASP Net 4.72 console app we receive this error:


Aspose.Slides.PptxReadException
HResult=0x80131500
Message=System.Drawing is not supported on this platform.
Source=Aspose.Slides
StackTrace:
at ​ .(Presentation , Stream , InterruptionToken )
at Aspose.Slides.Presentation.(Stream , Boolean )
at Aspose.Slides.Presentation.(Stream , Boolean )
at Aspose.Slides.Presentation.(String , Boolean )
at Aspose.Slides.Presentation…ctor(String file)
at ClassLibrary.AsposeTest.Test() in C:\Users\Administrator\Source\Repos\AsposeStandardTest\ClassLibrary\AsposeTest.cs:line 9
at AsposeStandardTest.Program.Main(String[] args) in C:\Users\Administrator\Source\Repos\AsposeStandardTest\AsposeStandardTest\Program.cs:line 9

This exception was originally thrown at this call stack:
System.Drawing.Image.FromStream(System.IO.Stream)
Aspose.Slides.ImageCollection.( ​ )
​ .( )
​ .( )
​ .( , Aspose.Slides.IPresentation)
​ .(Aspose.Slides.Presentation, System.IO.Stream, Aspose.Slides.InterruptionToken)

Inner Exception 1:
PlatformNotSupportedException: System.Drawing is not supported on this platform.


The same setup does work for Aspose.Cells but apparently not for Aspose.Slides.

  1. any chance you can fix this?
  2. are there any plans to remove the dependency on System.Drawing? Aspose.Words is using SkiaSharp and Aspose.Pdf is in the progress of migrating to Aspose.Imaging.

AsposeStandardTest.zip (548.7 KB)

@Fred.Net,

I have worked with the sample project and have created an issue with ID SLIDESNET-41561 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@Fred.Net

In the solution project that you have shared with us, there’re two projects.

1: The first represents the .NET Standard library using Aspose.Slides
2: The second is targeting .NET 4 (which referencing the library created in first project).

Actually, .NET Standard is not a platform but is a specification that various .NET platforms must implement in order to remain .Net Standard compliant (e.g. .NET Core is a runtime environment that implements .NET Standard specification). Therefore, .NET Standard defines a set of APIs that the platform must implement. We can’t create .NET Standard application, since an application must use the real .NET Standard implementation (like .NET Framework or .NET Core). We only can create a library, a general code, which then will be used by an application (targeting a particular platform).

Since the GDI+ library (which Aspose Slides depend on) has its own implementation for each specific platform, the dependency included in the .NET Standard project (this is the System.Drawing.Common package). This is only an abstraction that declares that Slides needs something, that System.Drawing.Common package has described in its API, and does not have a specific implementation.

By incorporating our .NET Standard library into the .NET Framework 4 project, we leave our abstraction unimplemented, even though the required library is moved to the working directory. Even if this library (System.Drawing.Common.dll) is included in the .NET Framework 4 project, it will not fix the issue - this library is still .NET Standard abstraction, that must be “implemented” for a particular platform.

In order to implement it (e.g. provide the implementation for an abstraction), one need to include a platform-specific System.Drawing.Common package in the project (NuGet itself will determine the exact library that should be used for this platform). If you look at the internal structure of System.Drawing.Common for .NET Framework 4, you will observe that this library references to System.Drawing, which is the GDI+ built-in library for Windows.

Thus, when using a library compiled as .NET Standard, the project must also include platform-dependent packages used by the .NET Standard library. I hope the shared elaboration will be helpful.

The issues you have found earlier (filed as SLIDESNET-41561) have been fixed in this update. This message was posted using Bugs notification tool.