Attempt to read or write protected memory Aspose.Slides 17.3.0.0

Hi,


We have a problem with Aspose.Slides 17.3.0.0.
The problem is not easy to isolate. We run a lot of code basically generating a PowerPoint document on the fly.
The error occurs when we have 3 users trying to generate a PowerPoint document at the same time.
The error is always the same “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”, but it appears either in
ShapeCollection.UpdateSelectedValue() or in Aspose.Cells.Drawing.Picture.ToImage()

These are the errors

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Drawing.SafeNativeMethods.Gdip.GdipFillPath(HandleRef graphics, HandleRef brush, HandleRef path)
at System.Drawing.Graphics.FillPath(Brush brush, GraphicsPath path)
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ​ ( )
at . ( , Stream , , ImageOrPrintOptions )
at . (Int32 , Stream , ImageOrPrintOptions )
at . (Int32 , ImageOrPrintOptions , Stream )
at Aspose.Cells.Drawing.Shape.UpdateSelectedValue()
at Aspose.Cells.Drawing.ShapeCollection.UpdateSelectedValue()


System.AccessViolationException was unhandled
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=System.Drawing
StackTrace:
at System.Drawing.SafeNativeMethods.Gdip.IntGdipDisposeImage(HandleRef image)
at System.Drawing.Image.Dispose(Boolean disposing)
at System.Drawing.Image.Dispose()
at . ()
at . ()
at . ()
at . (ImageOrPrintOptions , Shape )
at Aspose.Cells.Drawing.Picture.ToImage(ImageOrPrintOptions createImageOptions)

Can you provide a solution please?

Thank you in advance

Hi Raluca,


I have observed your comments. Can you please share sample working project so that we can further investigate to help you out.

Best Regards,

Hello,


This is the best we could do to provide something that reproduces the issue.
It’s different from how we do it in our project
And it doesn’t always work, sometimes you have to run this for 4-5 times in quick succession to see the protected memory error as opposed to other errors or no error at all.
Hope this is helpful for you.

Hi,


Thanks for sharing the sample project with template file.

After an initial test, I am able to reproduce the issue as you mentioned by using your sample project with your template file. I found an exception when running the solution second time:
“An unhandled exception of type ‘System.AccessViolationException’ occurred in System.Drawing.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
See the screenshot of the error: http://prntscr.com/eyu31d

I have logged a ticket with an id “CELLSNET-45300” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.
(Note: I have moved your thread to Aspose.Cells forum)

Thank you.

Hi,


See the thread for your reference (similar problem occured there too): <a rel=“nofollow” href="https://forum.aspose.com/t/91633

There are too many GDI objects being used in ToImage() method. I am afraid, we cannot add a lock for each of them. We think the best way to cope with it is to add a lock to ToImage() method.

Thank you.