Exception: System.Security.Permissions.EnvironmentPermission

Hello,

I am creating a sharepoint webpart that uses the Aspose.Word and Aspose.Pdf components to concenate all the doucments from a document library into 1 PDF document.

This is the part of the solution that causes the problem:

Document srcDoc = new Document(saveTmpDirectory + bestand.Name);

srcDoc.SaveOptions.ExportImagesFolder = @"F:\Temp\generateWord\";

srcDoc.SaveOptions.HtmlExportImagesFolderAlias = @"F:\Temp\generateWord\";

srcDoc.Save(saveTmpDirectory + nieuweBestandsNaam + ".xml", SaveFormat.AsposePdf);

// een pdf bestand maken van het word bestand

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

pdf.BindXML(saveTmpDirectory + nieuweBestandsNaam + ".xml", null);

pdf.IsImagesInXmlDeleteNeeded = true;

pdf.Save(saveTmpDirectory + nieuweBestandsNaam + ".pdf");

I am getting the following exception: System.Security.Permissions.EnvironmentPermission.

I am saving the pdf file locally and have given sharepoint the rights to save at the directory. The xml files are generated correctly when i remove the pdf.save

What can cause the exception?

I have tested giving write right to the windows temp dir but this doesnt solve the problem.

Thanks for the help!

Hi,

I have not been able to reproduce the error that you have reported. Can you please provide us with complete source code as well as input files that you are using so that we can more accurately determine the cause of the problem.

Thanks.

We need to investigate this issue on detail but I think Aspose.Pdf accessed environment variables. Is it possible to grant the permission for accessing environment variables?

Thank you.

I solved the problem by adding:

<IPermission
class="EnvironmentPermission"
version="1"
Unrestricted="true"
/>

to the wss_medium.config