"Out of Memory" Error under hosted permission set. doc.Save()

I downloaded Aspose.Words eval version today (v 4.0.1.0) and I am trying to get this to work under a hosted permission set. I'm using VS2005

I started by installing the .msi file. Fired up the Aspose.Words.Demo ASP.NET project. Got this running and exporting to both PDF and DOC files (all good!!)

I then switched over to use the hosted configuration. (I can supply if required). I had to make some changes to file paths (this config doesn't let you read above your ApplicationDirectory). I had to change the "ExportImagesFolder" (I dont have write access to TEMP directory, so I setup my own under the root of the web directory). Got the "DinnerInvitationDemo" to export as a DOC format, but no luck exporting to PDF. I get an "Out of Memory Exception" in "System.Drawing" (I can attach the stack trace if required).

Strange thing is that when I export the "EmployeesReport" demo to PDF it does work ?!?! Any ideas??? Maybe something to do fixed images in the document.

Regards,
Grant

Hi Grant,

Thank you for your interest in Aspose.Words and for reporting this problem to us. Please attach the configuration file and the stack trace of the exception. We will try to find out what the problem is.

Best regards,

Thanks for the fast reply.

I have uploaded the files necessary to replicate the hosted permission set (zip file). There is a .TXT file in the ZIP file that explains how to setup hosted trust.

I get the following error when I call this line "doc.Save(stream, SaveFormat.AsposePdf);" in the sample code provided. Note: I am running the "DinnerInvitation" sample with PDF as my output format.

Stack Trace:

[OutOfMemoryException: Out of memory.]
   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) +337
   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement) +33
   System.Drawing.Image.FromStream(Stream stream) +27
   ᰽.᰼.᱌(Stream ᱋, Int32 څ, SizeF Ԥ) +212
   ᰽.᰼.᱊(Stream ᱋, Boolean ᱉, Int32 څ, SizeF Ԥ) +92
   ᰽.᰼.൥(Shape ೣ, Boolean ᱉, Int32 څ) +186
   ᰤ.ᳱ.᳼(Shape ೣ) +170
   ᰤ.ᳱ.᳻(Shape ೣ) +96
   ᰤ.ᳱ.᳹(Shape ೣ) +379
   ᰤ.ᳱ.᯹(Shape ೣ) +71
   ᰤ.᳛.᯹(Shape ೣ) +33
   ᰤ.ᰣ.VisitShapeStart(Shape shape) +33
   Aspose.Words.Drawing.Shape.Accept(DocumentVisitor visitor) +36
   Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ) +66
   Aspose.Words.Paragraph.Accept(DocumentVisitor visitor) +77
   Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ) +66
   Aspose.Words.Cell.Accept(DocumentVisitor visitor) +84
   Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ) +66
   Aspose.Words.Row.Accept(DocumentVisitor visitor) +84
   Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ) +66
   Aspose.Words.Table.Accept(DocumentVisitor visitor) +84
   Aspose.Words.CompositeNode.ނ(DocumentVisitor ރ) +66
   Aspose.Words.Body.Accept(DocumentVisitor visitor) +77
   ᰤ.ᰣ.ᮽ(Section అ) +92
   ᰤ.ᰣ.᮹(ᮘ ᮗ) +263
   Aspose.Words.Document.ݦ(Stream ݡ, String ݟ, SaveFormat ݧ) +134
   Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat) +74
   Aspose.Words.Demos.Viewer.SendToBrowserAsPdf(Document doc) +172
   Aspose.Words.Demos.Viewer.SendToBrowser(Document doc, String outputFormat) +535
   Aspose.Words.Demos.Viewer.Page_Load(Object sender, EventArgs e) +331
   System.Web.UI.Control.OnLoad(EventArgs e) +88
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3035

Thanks for providing additional info. Please give me one more day for research. I will inform you as soon as I will succeed in finding the cause of the problem.

Best regards,

So far I have found that under the "hosted trust" config you have provided the following code fails with "Out fo memory." exception:

Image metafile = Image.FromStream(imageStream)

The stream is a correct image and I have verified that it is is absolutely the same that is provided when running with full trust web.config. I don't know why this function fails but it is clear that some security limitations prevent it from executing correctly.

It fails even in case when I do:

byte[] bytes = ((MemoryStream)imageStream).ToArray();

MemoryStream ms = new MemoryStream(bytes);

Image metafile1 = Image.FromStream(ms);

In the same time the following code executes correctly:

File.WriteAllBytes(@"C:\Program Files\Aspose\Aspose.Words\Demos\Aspose.Words.Demos\metafile1.wmf", ((MemoryStream)imageStream).ToArray());

Image metafile2 = Image.FromFile(@"C:\Program Files\Aspose\Aspose.Words\Demos\Aspose.Words.Demos\metafile1.wmf");

So saving the stream of bytes to file and loading image from this file executes ok, while direct load from stream is somehow prevented by "hosted trust" security settings. That is something beyond my understanding.

I am sorry to admit it but I am out of ideas at the moment. Please let me know if you have any ideas on why this is happening and how it can be fixed or worked around.

Best regards,