简体   繁体   English

System.Security.SecurityException:该程序集不允许部分信任的调用者

[英]System.Security.SecurityException: That assembly does not allow partially trusted callers

i am creating pdf by using itextsharp.dll, local it is working fine. 我正在使用itextsharp.dll创建pdf,本地它工作正常。 but server am facing below error .i have added assemblyinfo.cs ..but same error is coming.Specifically, I modified the AssemblyInfo.cs file by adding these references and attribute: 但服务器面临以下错误.i已添加assemblyinfo.cs ..但同样的错误即将到来。具体来说,我通过添加这些引用和属性修改了AssemblyInfo.cs文件:

using System.Security; 使用System.Security; using System.Security.Permissions; 使用System.Security.Permissions; [assembly: AllowPartiallyTrustedCallers] [assembly:AllowPartiallyTrustedCallers]

in my form the pdf throws an error at myDocument.. It never go to read it n throws the below error... 在我的形式pdf在myDocument上抛出一个错误..它永远不会去读它n抛出以下错误...

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

still am getting the error in server .. can anyone help me out 仍然在服务器中收到错误..任何人都可以帮助我

Server Error in '/' Application. '/'应用程序中的服务器错误。 Security Exception Description: The application attempted to perform an operation not allowed by the security policy. 安全异常说明:应用程序尝试执行安全策略不允许的操作。 To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 要授予此应用程序所需的权限,请与您的系统管理员联系或在配置文件中更改应用程序的信任级别。

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers. 异常详细信息:System.Security.SecurityException:该程序集不允许部分信任的调用方。

Source Error: 来源错误:

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

Source File: d:\\hosting\\bookgroupadmin\\agent\\checkbeforprintconf.aspx.cs Line: 218 源文件:d:\\ hosting \\ bookgroupadmin \\ agent \\ checkbeforprintconf.aspx.cs行:218

Stack Trace: 堆栈跟踪:

[SecurityException: That assembly does not allow partially trusted callers.] finalgroup_checkbeforprintconf.btn_Click(Object sender, EventArgs e) in 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 context) +18 System.Web.UI.P [SecurityException:该程序集不允许部分受信任的调用者。]在d:\\ hosting \\ bookgroupadmin \\ agent \\ checkbeforprintconf.aspx.cs中的finalgroup_checkbeforprintconf.btn_Click(Object sender,EventArgs e):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 context)+18 System.Web。 UI.P age.ProcessRequest(HttpContext context) +49 ASP.checkbeforprintconf_aspx.ProcessRequest(HttpContext context) in App_Web_ovcuievo.18.cs:0 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64 app.Web_ovcuievo.18.cs中的age.ProcessRequest(HttpContext context)+49 ASP.checkbeforprintconf_aspx.ProcessRequest(HttpContext context):0 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+358 System.Web.HttpApplication .ExecuteStep(IExecutionStep step,Boolean&completedSynchronously)+64

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; 版本信息:Microsoft .NET Framework版本:2.0.50727.1433; ASP.NET Version:2.0.50727.1433 ASP.NET版本:2.0.50727.1433

The best thing about it though is that it can run in Medium trust mode - once a minor change is made to allow partially trusted callers. 关于它的最好的事情是它可以在中等信任模式下运行 - 一旦做出微小的改变以允许部分信任的呼叫者。 To make this change download the iTextSharp source distribution ( http://sourceforge.net/projects/itextsharp/files/ ) Modify the AssemblyInfo.cs file to add the partially trusted callers attribute. 要进行此更改,请下载iTextSharp源代码分发( http://sourceforge.net/projects/itextsharp/files/ )修改AssemblyInfo.cs文件以添加部分受信任的调用者属性。

[assembly: AllowPartiallyTrustedCallers()]

Rebuild the iTextSharp assembly and it should be good to go in a Medium trust environment. 重建iTextSharp程序集,最好进入中型信任环境。

Most probably the library that you use does not support a medium trust environment (most shared hosting companies). 很可能您使用的库不支持中等信任环境(大多数共享托管公司)。 It might not be your code that throws the error, but the third party - make sure that they do support this. 它可能不是你的代码抛出错误,而是第三方 - 确保他们支持这个。

If the stack trace ends in a portion of code written by you, then please provide this code, currently it is not clear what exactly doesn't have permissions to run. 如果堆栈跟踪以您编写的代码的一部分结束,那么请提供此代码,目前尚不清楚究竟什么没有运行权限。

I got the same issue and it has solved by creating another folder, move all the contents to that and change the application path to the new folder. 我遇到了同样的问题,它通过创建另一个文件夹,将所有内容移动到该文件并将应用程序路径更改为新文件夹来解决。 I can't say that how it solved fore sure. 我不能说它是如何解决的。 But it worked for me. 但它对我有用。 I believe it has due to some caching issue in IIS. 我相信它是由于IIS中的一些缓存问题。

Hope this will help you guys. 希望这会帮助你们。

I also faced this type problem and resolved by follow the instruction of below link. 我也遇到了这种类型的问题,并按照以下链接的说明解决。 it is so helpful it save my 3 days hard work. 它是如此有用,它节省了我3天的辛勤工作。 You can try this 你可以试试这个

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

Last 2 more step doing by me which is not mentioned 1. Remove old reference of iTextsharp from your project. 最后两步我做的没有提到1.从你的项目中删除iTextsharp的旧参考。 2. Add new iTextsharp dll reference in your project. 2.在项目中添加新的iTextsharp dll参考。 which is make by you. 这是你做的。 Then publish your project. 然后发布您的项目。 Do not directly paste the new itextsharp.dll in your server with old publish code. 不要使用旧的发布代码直接将新的itextsharp.dll粘贴到服务器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Security.SecurityException:该程序集不允许部分信任的调用者 - System.Security.SecurityException: That assembly does not allow partially trusted callers SecurityException:该程序集不允许部分受信任的调用方 - SecurityException: That assembly does not allow partially trusted callers 部署时“该程序集不允许部分受信任的呼叫者” - “That assembly does not allow partially trusted callers” on deployment 该程序集不允许部分受信任的呼叫者 - That assembly does not allow partially trusted callers 该程序集不允许部分受信任的呼叫者,尽管该区域是完全受信任的 - That assembly does not allow partially trusted callers although the zone is fully trusted C#-.NET 4.0-该程序集不允许部分受信任的调用方 - C# - .NET 4.0 - That Assembly does not allow partially trusted callers 该程序集不允许部分信任的调用者。 的InitializeComponent() - That assembly does not allow partially trusted callers. InitializeComponent() 使用自定义解析器时,程序集不允许部分受信任的调用者 - Assembly does not allow partially trusted callers when using a custom resolver Unity配置错误-该程序集不允许部分受信任的调用者 - Unity configuration error - That assembly does not allow partially trusted callers System.Security.SecurityException - System.Security.SecurityException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM