开发者

Reflection and attributes -- removal? modification? OR windows service in full trust?

开发者 https://www.devze.com 2023-01-10 00:01 出处:网络
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 att开发者_运维知识库ribute?

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 att开发者_运维知识库ribute?

[...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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消