Thursday, July 10, 2008

iTextSharp will not run in a partially trusted environment

I ran into this problem last week where my iTextSharp component was failing on on remotely hosted website due to it expecting to be running in a Fully Trust environment. So, the fix here is to download the source files of iTextSharp and do the following:

  • Add [assembly:AllowPartiallyTrustedCallers] to the assembly.cs (assuming c#)
  • Rebuild the project
  • Copy the DLL (or reference) to your /bin directory in your project

That's it. If you want to know more about AllowPartiallyTrustedCallers attribute from Microsoft, click here. If you need to download the source files for iTextSharp, click here.

Hope that helps.