ProtectionManager.Encrypt Method Throws NullReferenceException on Linux

Dear Aspose Developers,

the ProtectionManager.Encrypt function does not work on Linux, it throws a nullreference exception, when i am trying to encrypt a pptx file on Linux.
Please investigate the issue!

Thank you in advance!

@aerenyi,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides if possible. If the issue persists, please share the following files and information:

  • sample presentation file
  • code example that reproduces the error
  • OS version on which the code was executed
  • .NET target platform in your app
  • Aspose.Slides version you used

Dear Andrey,

The details are the following:

The pptx that i used for testing might contain confidential information, therefore i retested with a sample file (bemutato.pptx) and i received a different error:

System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.

Aspose.Slides.NET version 23.11.0
.Net target platform is .net 6
Linux version is: 6.0.25-bullseye-slim (running as docker image: mcr.microsoft.com/dotnet/aspnet:6.0.6-bullseye-slim

The code snippet below:

using (var inputStream = new MemoryStream(file))
{
	Aspose.Slides.LoadFormat loadFormat = Aspose.Slides.PresentationFactory.Instance.GetPresentationInfo(inputStream).LoadFormat;

	if (loadFormat != Aspose.Slides.LoadFormat.Unknown)
	{
		using (var document = new Aspose.Slides.Presentation(inputStream))
		{
			document.ProtectionManager.Encrypt(password); --> this line throws the error according to the stacktrace
			Aspose.Slides.Export.SaveFormat saveFormat = GetSaveFormat(loadFormat);
			document.Save(outputStream, saveFormat);
		}

		outputStream.Seek(0, SeekOrigin.Begin);
		return outputStream.ReadFully();
	}
}

bemutato.zip (321,9 kB)

Thank you in advance!
Best regards,
Andras

@aerenyi,
Thank you for the additional information. Please see the following article and configure your project appropriately:

Dear Andrey,

I followed the instructions, but now i am getting this error:

System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
at System.Drawing.Image…ctor()
at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)
at e.(Size ,  )
at e.(Size )
at Aspose.Slides.Slide.GetThumbnail(Size imageSize)
at .(e , IPresentation )
at .(Presentation , Stream ,  , IPptxOptions , InterruptionToken )
at Aspose.Slides.Presentation.(Stream ,  , IPptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)

Can you please tell me, what else shall be done?

@aerenyi,
We apologize that you had to encounter this error. Could you please share the Dockerfile you used?

Dear Andrey,

Please see the dockerfile here.

Best regards,
Andras

@aerenyi,
Thank you for the Dockerfile. Please try using Aspose.Slides.NET6.CrossPlatform:

I hope this helps you and the error goes away.