在 Medium Trust 中调用内部方法
我需要调用第三方对象的内部方法(例如,我不能将其公开)。 我可以通过反思来做到这一点。 不幸的是,由于权限不足,这在 ASP.NET 中等信任中不起作用:
<IPermission class="ReflectionPermission" version="1" Flags="RestrictedMemberAccess"/></PermissionSet>
在这种情况下,有什么办法可以使用内部方法吗? 我听说 LINQ 表达式可用于调用私有/内部方法。 表达式方法会以某种方式覆盖 ReflectionPermission 吗?
I have the requirement to call an internal method of a 3rd party object (I cannot make it public for example). I can do that via reflection. Unfortunately this does not work in ASP.NET Medium trust due to insufficient rights:
<IPermission class="ReflectionPermission" version="1" Flags="RestrictedMemberAccess"/></PermissionSet>
Is there any way I can internal methods in this case? I've heard that LINQ expressions can be used to call private/internal methods. Would expression methods somehow override the ReflectionPermission?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看不到调用它的方法。 .NET 安全/信任模型旨在防止此类事情发生。 如果您能以某种方式规避它,则必须向 Microsoft 提交一个安全错误,然后(希望)该错误会被修复并使您的解决方案再次变得无用;-)
您不能与您的部署者/操作员协商更高的信任级别吗?解决方案?
I don't see a way to call it. The .NET security/trust model is designed to prevent exactly this sort of thing. If you could somehow circumvent it, you would have to file a security bug with Microsoft which would then (hopefully) be fixed and make your solution useless again ;-)
Can't you negotiate a higher trust level with the deployer/operator of your solution?