Free Support Forum - aspose.com

Problem with Aspose Words 5.0.0.0 / Apose PDF 3.6.2.0 - Attempted To Read or Write Protected Memory

Hi,

we are currently getting the error 'Attempted to Read or Write Protected Memory - this is often an indication of other memory that is corrupt' when calling the Pdf Save method e.g.

pdf.save(docName, Aspose.Pdf.SaveType.OpenInAcrobat, this.Response)

We are loading word template pages into Aspose.Words and then saving the merged document out into PDF format. We have upgraded Apose.words to version 5.0.0.0 as a lot of people on the forums are saying this cures this problem, but unfortunately this has not cured our problem.

We have already tried the following :-

Upgraded our Aspose.Words dll to version 5.0.0 as per the various discussions we have been reading on the aspose forums.

Registered the Apose.words and Aspose.PDF.dll in GAC

Granted read and write permissions on each of the dll's

The Code snippet can where the problems are occuring can be found below :-

private void SendToBrowserAsPdf(Document doc, string documentprinted, string docName, string internalname)

{

MemoryStream stream = new MemoryStream();

doc.Save(stream, SaveFormat.AsposePdf);

stream.Seek(0, SeekOrigin.Begin);

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(stream);

string pdflicensefile = MapPath(@"..\bin\Aspose.Pdf.lic");

if (System.IO.File.Exists(pdflicensefile))

{

Aspose.Pdf.License pdflic = new Aspose.Pdf.License();

pdflic.SetLicense(pdflicensefile);

}

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

pdf.IsImagesInXmlDeleteNeeded = true;

pdf.BindXML(xmlDoc, null);

pdf.IsTruetypeFontMapCached = false;

try

{

pdf.Save(docName, Aspose.Pdf.SaveType.OpenInAcrobat, this.Response); // THIS IS WHERE THE ERROR IS GENERATED!

}

catch (Exception ex_)

{

Response.Write(ex_.Message.ToString()));

}

}

Any help would be much appreciated,

Paul

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Please make sure that your application uses Aspose.Words v5.0.0. Most probably your application uses old version.

Also I would like to advice you to upgrade to the latest versions of Aspose.Words and Aspose.Pdf.

http://www.aspose.com/community/files/51/file-format-components/aspose.words/entry133970.aspx

http://www.aspose.com/community/files/51/file-format-components/aspose.pdf/entry133741.aspx

Best regards.