反射和属性——移除?修改?或者完全信任Windows服务?
我想从我无权访问其源代码的类中删除安全权限。是否可以通过反射删除或修改属性?
[...PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust"), PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
经过一番考虑,我发现这种解决问题的方法可能是错误的。有没有一种方法可以完全信任地运行Windows服务,使其权限满足上述要求?
I want to remove the security permissions from a class I don't have access to the source for. Is it possible to, via reflection, remove or modify the attribute?
[...PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust"), PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
after some consideration, it's occurred to me that maybe this approach to the problem is wrong. Is there a way to run a windows service in full trust so that its permissions would satisfy the above demands?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不 - .NET 反射是只读的。如果您想编辑现有程序集,请查看 Mono Cecil,尽管删除了属性 &替换程序集将删除其上签名的任何强名称
Nope - .NET reflection is read-only. If you want to edit an existing assembly, look at Mono Cecil, although removing an attribute & replacing the assembly would remove any strong name signing on it
您始终可以创建一个包装类并赋予该包装类更受限制的权限。
You can always create a wrapper class and give the wrapper class more restricted permissions.