What Reflection Permission are allowed in Medium Trust?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 03:59:16

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!