Tuesday, 20 March 2012

Creating PDF Using ITextSharp showing System.Security.Permissions.EnvironmentPermission, mscorlib, Version = 1.0.50000.0, Culture = neutral, publicKeyToken = [number] failed error.


Sometimes when you are using ITextSharp for creating PDF's might throw the error in the production environment that System.Security.Permissions.EnvironmentPermission, mscorlib, Version = 1.0.50000.0, Culture = neutral, publicKeyToken = [number] failed error. This is because the ITextSharp doesn't work on minimum security level, so in order to work just download the ITextSharp all source code(Here is the Link: ITextSharp )
Now extract it and open it in your Visual Studio 20008/2010.
Open Assemplyinfo.cs and Add this line: [assembly: AllowPartiallyTrustedCallers()]
Save it and Build the Solution, Go to the \itextsharp-src-core-5.2.0\bin\Debug folder and copy the itextharp.dll and the Xml file to your production Environment.

Enjoy....

No comments:

Post a Comment