Recently I got one
requirement where I need to create PDF file and upload it as an attachment to
list item from a Sandbox solution
Normally we can create
PDF file using ITextSharp dll without any issue in Farm solution.
But in sandbox solution,
this solution gave below errors
- Assembly could not load error as we are adding external dll to sandbox
- System.Security.SecurityException: exception because ITextSharp assembly does not allow partially trusted callers
Make ITextSharp dll
partial trust:
- Download ITextSharp solution Download iTextSharp
- Open AssemblyInfo.cs of ‘ITextsharp-src-core’ project
- Add below line in AssemblyInfo.cs
[assembly: System.Security.AllowPartiallyTrustedCallers]
Recompile solution and take latest itextsharp dll
Recompile solution and take latest itextsharp dll
Now add this dll to
sandbox solution bin folder and add it in project references
Add dll to Solution
package
Next step is to use the
package configuration in order to deploy this assembly to Sandbox GAC
cache. All 3rd party assemblies should be configured in sandbox
solution package
1. Open solution package and add dll from bin
folder
Rebuild and deploy
the sandbox solution.
Now you can use ITextSharp methods to create PDFs



