开发者

What Reflection Permission are allowed in Medium Trust?

开发者 https://www.devze.com 2023-02-03 09:25 出处:网络
I want to ask that which methods/classes are allowed in Medium Trust. For example, whether these methods are allowed?

I want to ask that which methods/classes are allowed in Medium Trust. For example, whether these methods are allowed?

GetProperties, GetMethods, Activator.CreateInstance,开发者_如何学运维 Assembly.Version, AssemblyName.Name

Please tell me which methods are allowed.


GetMethods and Activator.CreateInstance should be allowed IIRC, whilst AssemblyName and Assembly.Version aren't. I've used the first two methods in Medium-Trust environments and the latter two didn't work. Best way is just through trial-and-error really. Also might help by using Reflector when you do get stuck, to find out why stuff isn't allowed (normally [PrincipalPermission(SecurityAction.Demand, AspNetHostingPermission.High/Full)] attribute on a class somewhere higher up the call stack).

HTH,

Benjamin


Tools like permview (.NET 1.1 only) or permcalc (.NET 2.0) can help tell you about the security permission demands your assembly or assemblies will require; it's a little easier than doing trial-and-error bases analysis because you might forget to manually exercise a code path that tries to do a security-related demand.

Unfortunately the MSDN documentation doesn't explicitly list the security requirements of every method or property call.

0

精彩评论

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

关注公众号