简体   繁体   English

使用自定义解析器时,程序集不允许部分受信任的调用者

[英]Assembly does not allow partially trusted callers when using a custom resolver

I have an assembly on the intranet calling to another library on the intranet (in a different folder) which then calls Microsoft HPC API which is installed in the local machine GAC. 我在Intranet上有一个程序集,该程序集调用到Intranet上的另一个库(在另一个文件夹中),该库然后调用安装在本地计算机GAC中的Microsoft HPC API。

The assembly finds the library using the method in MS KB 837908 and in the process a SecurityException is raised "That assembly does not allow partially trusted callers" (That assembly is the HPC API) 程序集使用MS KB 837908中的方法找到该库,并在此过程中引发SecurityException“该程序集不允许部分受信任的调用者”(该程序集是HPC API)

However if I move the library in the same folder on the intranet as the executing assembly (ie. there is no need to call the custom resolver) it all works fine. 但是,如果我将库与正在执行的程序集移动到Intranet上的同一文件夹中(即,无需调用自定义解析器),则一切正常。

How can I improve the custom resolver to avoid this security exception? 如何改进自定义解析器以避免此安全异常?

a SecurityException is raised "That assembly does not allow partially trusted callers" 引发SecurityException“该程序集不允许部分受信任的调用者”

That's a good thing. 这是好事。 If the assembly was not marked with the Allow Partially Trusted Callers attribute, that means that either (1) the authors of that assembly never performed a security review to see if it was safe to be called by hostile partially trusted code, or (2) did perform a security review, and did determine that the assembly was not safe to be called by hostile partially trusted code . 如果该程序集未标记有“允许部分信任的调用者”属性,则意味着(1)该程序集的作者从不执行安全检查以查看是否可以安全地被敌对的部分信任的代码调用,或者(2)确实执行了安全审查, 并确定由恶意的部分受信任的代码调用该程序集并不安全

This exception is protecting your users from harm, and so you should be glad that it is thrown. 此异常可以保护您的用户免受伤害,因此您应该为它被抛出而感到高兴。

However if I move the library in the same folder on the intranet as the executing assembly it all works fine. 但是,如果我将库与执行程序集移动到Intranet上的同一文件夹中,则一切正常。

Well then, it sounds like you've solved your problem. 好吧,听起来您已经解决了问题。

How can I improve the custom resolver to avoid this security exception? 如何改进自定义解析器以避免此安全异常?

You're asking how to work around a correctly-working security system that is protecting your users from attacks by hostile partially trusted code ? 您在问如何解决能够正常工作的安全系统,该系统通过恶意的部分受信任的代码保护用户免受攻击 Why on earth would you want to do that? 您到底为什么要这样做? If you could do that successfully I hope you would tell Microsoft about it so that we could fix the bug and prevent you from doing that . 如果您可以成功完成此操作,希望您能将此问题告知Microsoft,以便我们修复该错误阻止您这样做

Do not work around security systems; 不要绕过安全系统; work with security systems. 安全系统一起工作。 If the problem is that you are calling a component that requires a fully trusted caller then either (1) don't call that component, or (2) instruct your users to set policies that fully trust the caller. 如果问题在于您正在调用需要完全信任的调用者的组件,则(1)不要调用该组件,或者(2)指示用户设置完全信任调用者的策略。

Hans Passant provided this solution in the comments , I've extended an offer to him to provide a formal answer and I'll be happy to accept it. 汉斯·帕桑特(Hans Passant)在评论中提供了此解决方案 ,我已经向他提供了一个正式答案,我很乐意接受。

Using the Microsoft KB sample linked in question change 使用链接中的Microsoft KB示例进行更改

MyAssembly = Assembly.LoadFrom(strTempAssmbPath);

to

Assembly.LoadFrom(strTempAssmbPath, Assembly.GetExecutingAssembly().Evidence)

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

相关问题 部署时“该程序集不允许部分受信任的呼叫者” - “That assembly does not allow partially trusted callers” on deployment 该程序集不允许部分受信任的呼叫者 - 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 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() System.Security.SecurityException:该程序集不允许部分信任的调用者 - System.Security.SecurityException: That assembly does not allow partially trusted callers System.Security.SecurityException:该程序集不允许部分信任的调用者 - System.Security.SecurityException: That assembly does not allow partially trusted callers Unity配置错误-该程序集不允许部分受信任的调用者 - Unity configuration error - That assembly does not allow partially trusted callers 程序集不允许部分受信任的调用者 - Assembly does not allow partially trusted caller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM