3

I'm trying to generate a PDF in memory to send it to a WS. This PDF should be created in memory (Stream) and in the Microsoft CRM "cloud" in a plugin code. Is this possible?

In the plugin (already coded and deployed) I have this lines, the 3th fails

PdfDocument pdf = new PdfDocument();
PdfPage pdfPage = pdf.AddPage();

XGraphics graphics = XGraphics.FromPdfPage(pdfPage); //<-- ERROR

is this line of code trying to access a resource in the cloud that is not permitted/available?

this is the error:

Unexpected exception from plug-in (Execute): Plugins8.Plugin: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

any ideas?

Filburt
  • 17,626
  • 12
  • 64
  • 115
demian
  • 632
  • 7
  • 14
  • In my case it now turned out to be Serialization: In my plugin I serialize an Entity to Xml and this doesn't seem to be possible in Sandboxed plugins. I can still use Streams so this could be ruled out as the cause. – Filburt Mar 20 '15 at 20:04

1 Answers1

0

I assume you are using PDFsharp and you have its libraries merged into your plugin assembly using ILMerge.

If so, the SecurityException can be caused by PDFsharp using GDI+. In partial trusted app domains drawing graphics with GDI+ is not allowed. You can however compile PDFsharp for WPF. Try compiling PDFsharp with directives WPF plus (maybe) SILVERLIGHT.

Henk van Boeijen
  • 7,357
  • 6
  • 32
  • 42