Hello,
we use Aspose.Words (Cells and Slides) in SharePoint for watermarking in pdf. Our solutions runs in Application-Context (IIS bin folder) an Aspose-Compontents are in GAC.
With CAS-Policies we configured the rights as far as we can see. Just FileIOPermission will shown.
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Read="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\;L:\MOSS\FileLog;$AppDir$"
Write="L:\MOSS\FileLog;$AppDir$"
Append="L:\MOSS\FileLog;$AppDir$"
PathDiscovery="L:\MOSS\FileLog;C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\;$AppDir$" />
So it runs, an the documents from SharePoint Site (Library) can be load into a Words.Document. After that the Document should be stored as PDF into a MemoryStream, that we kann add a stamp (watermark) to it with the Aspose.Pdf.Kit.
The exeption occurs when we use the folliwing lines of code:
_doc = new Document(fileStream); //--> that works
_logger.Info("Finished loading file!");
_logger.Trace("Save Word document into memory stream as Pdf format.");
_doc.Save(_pdfStream, SaveFormat.Pdf); //--> that fails
When do I raise the permission to FullTrust, no Error occurs, so what happens inside Aspose.Words (and others), that an FileIOPermission is necessary even if I use a MemoryStream??
Here is the ErrorLog:
2/19/2010 7:32:15 AM Verbose WATERMARK - WordBuilder Save Word document into memory stream as Pdf format. 5648 c:\windows\system32\inetsrv\w3wp.exe 5976
2/19/2010 7:32:15 AM Error WATERMARK - WordBuilder Loading Word file failed. Message: The type initializer for '䡄.䤍' threw an exception.
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark & stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.get_SystemDirectory()
at 䡄.䤍.䥆()
at 䡄.䤍..cctor()
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.FileIOPermission
The Zone of the assembly that failed was:
MyComputer - Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Trace: at 䡄.䤍.ੴ(String 㜃, FontStyle ৢ, Boolean 䤣)
at 䞑.䠳..ctor(䟟 context, String familyName, FontStyle requestedStyle)
at 䞑.䢙..ctor(䟟 context, String familyName, FontStyle requestedStyle)
at 䞑.䢈.ੴ(String 㜃, FontStyle ৢ, Boolean 䡁)
at 䞑.䫄.䫌(㈮ 䪰)
at 䞑.䪪.䖆(㈮ 䪰)
at ㈊.㈖.Accept(㈙ visitor)
at ㈊.㉄.Accept(㈙ visitor)
at ㈊.㈖.Accept(㈙ visitor)
at ㈊.㉄.Accept(㈙ visitor)
at ㈊.㈖.Accept(㈙ visitor)
at ㈊.㉄.Accept(㈙ visitor)
at ㈊.㈖.Accept(㈙ visitor)
at ㈊.㉄.Accept(㈙ visitor)
at ㈊.㈖.Accept(㈙ visitor)
at ㈊.㉄.Accept(㈙ visitor)
at ㈊.㈖.Accept(㈙ visitor)
at ㈊.㈚.Accept(㈙ visitor)
at Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, Stream stream, PdfOptions pdfOptions)
at Aspose.Words.Document.ԅ(Stream Ӿ, String Ӽ, SaveFormat Ԇ)
at MunichRe.cMOSS.Connect.Watermark.RenderEngine.AsposeBuilder.WordBuilder.Load(Stream fileStream) 5648 c:\windows\system32\inetsrv\w3wp.exe 5976