System.Security.SecurityException: this assembly does not allow partially trusted subscribers

I am creating pdf using itextsharp.dll, it works fine locally. but the server encounters an .i error added assemblyinfo.cs .., but the same error occurs. In particular, I modified the AssemblyInfo.cs file by adding these links and the attribute:

using System.Security; using System.Security.Permissions; [build: AllowPartiallyTrustedCallers]

in my form pdf throws an error in myDocument .. He never reads this n gives the following error ...

  Document myDocument = new Document(PageSize.A4, 70, 70, 70, 70);

there is still an error on the server .. can someone help me

Server error in application "/". Security exception Description: The application attempted to perform an operation not permitted by the security policy. To grant this application the required permissions, contact your system administrator or change the application trust level in the configuration file.

Exception Details: System.Security.SecurityException: This assembly does not allow partial trust for callers.

Source Error:

Line 216: HttpContext.Current.Response.End (); Line 217:
Line 218:} Line 219: protected void droplist_SelectedIndexChanged (object sender, EventArgs e) Line 220: {

Source file: d: \ hosting \ bookgroupadmin \ agent \ checkbeforprintconf.aspx.cs Line: 218

Stack trace:

[SecurityException: .]  finalgroup_checkbeforprintconf.btn_Click ( , EventArgs e) d:\hosting\bookgroupadmin\agent\checkbeforprintconf.aspx.cs: 218  System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105  System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107  System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7  System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350  System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213  System.Web.UI.Page.ProcessRequest() +86  System.Web.UI.Page.ProcessRequestWithNoAssert( HttpContext) +18  System.Web.UI.Page.ProcessRequest( HttpContext) +49  ASP.checkbeforprintconf_aspx.ProcessRequest( HttpContext) App_Web_ovcuievo.18.cs: 0  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358  System.Web.HttpApplication.ExecuteStep( IExecutionStep, Boolean ) +64

: Microsoft.NET Framework : 2.0.50727.1433; ASP.NET: 2.0.50727.1433

+3
4

, - , . , iTextSharp (http://sourceforge.net/projects/itextsharp/files/) AssemblyInfo.cs, .

[assembly: AllowPartiallyTrustedCallers()]

iTextSharp, .

+3

, , , ( ). , , , - , .

, , , , .

+2

, , . , . . , IIS.

, , .

+1

. , 3- .

https://www.aspsnippets.com/Articles/ASPNet-iTextSharp-SystemSecuritySecurityException-That-assembly-does-not-allow-partially-trusted-callers.aspx

The last two steps I have made that are not mentioned are 1. Remove the old iTextsharp link from your project. 2. Add a new link to the iTextsharp dll in your project. which you do. Then publish your project. You cannot directly paste the new itextsharp.dll file into your server with the old publication code.

0
source

Source: https://habr.com/ru/post/1706895/


All Articles