首页 新闻 会员 周边 捐助

关于反射调用非公共成员函数的问题

0
[已关闭问题] 关闭于 2011-12-15 14:33
MethodInfo method = typeof(BuildManager).GetMethod("ThrowIfPreAppStartNotRunning", BindingFlags.Static | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
dynamicModuleReflectionUtil.ThrowIfPreAppStartNotRunning = CommonReflectionUtil.MakeDelegate<Action>(method);
public static T MakeDelegate<T>(MethodInfo method) where T : class
{
return CommonReflectionUtil.MakeDelegate<T>(null, method);
}
public static T MakeDelegate<T>(object target, MethodInfo method) where T : class
{
return CommonReflectionUtil.MakeDelegate(typeof(T), target, method) as T;
}
[ReflectionPermission(SecurityAction.Assert, MemberAccess = true)]
public static Delegate MakeDelegate(Type delegateType, object target, MethodInfo method)
{
//ReflectionPermission permission = new ReflectionPermission(PermissionState.Unrestricted);
//permission.Assert();
return Delegate.CreateDelegate(delegateType, target, method);
}



这样调用会抛出权限异常,可是使用了断言了呀,何解?

IT Giant的主页 IT Giant | 初学一级 | 园豆:7
提问于:2011-12-15 13:06
< >
分享
所有回答(1)
0

修改web.config

IT Giant | 园豆:7 (初学一级) | 2011-12-15 14:32
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册