Hi
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();
Document currdoc;
try
{
currdoc = new Document(File.OpenRead(Server.MapPath(filepath + thisjob)));
currdoc.SaveOptions.ExportImagesFolder = Server.MapPath(@".\temp");
currdoc.Save(currstream, SaveFormat.Pdf);
}
catch (InvalidCastException e)
{
Response.Write(e.ToString());
Response.End();
}
return currstream;
}
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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.
Source Error:
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.
Stack Trace:
[SecurityException: Request for the permission of type ‘System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +58
System.Environment.get_SystemDirectory() +109
㌧.㍸.㎳() +22
㌧.㍸…cctor() +450
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082
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.