I am currently testing out Aspose.Words on one of my hosted development servers and I am getting an error when I try to save a document to PDF. The following is my code and the highlighted line is where the error appear to be happening.:
protected MemoryStream CreatePDFStream(string thisjob)
MemoryStream currstream = new MemoryStream();
currdoc = new Document(File.OpenRead(Server.MapPath(filepath+thisjob)));
currdoc.SaveOptions.ExportImagesFolder = Server.MapPath(@".\temp");
It is throwing the following error when it tries to save the file to PDF in a MemoryStream:
Server Error in '/' Application.
Security Exception Description:
The application attempted to perform an operation not allowed by the
security policy. To grant this application the required permission please
contact your system administrator or change the application's trust level in the
configuration file. Exception Details:
System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=188.8.131.52,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.Source
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
Microsoft .NET Framework Version:2.0.50727.3603;
I tried to give permissions to my Fonts folder as described in another post I saw but this did not solve my issue. I still get the same error.