System.Security.SecurityRuntime.GetMethodInfo C# (CSharp) Method

GetMethodInfo() static private method

static private GetMethodInfo ( RuntimeMethodHandle rmh ) : MethodInfo
rmh System.RuntimeMethodHandle
return System.Reflection.MethodInfo
        internal static MethodInfo GetMethodInfo(RuntimeMethodHandle rmh)
        {
            if(rmh.IsNullHandle())
                return null;

#if _DEBUG
            try
            {
#endif
                // Assert here because reflection will check grants and if we fail the check,
                // there will be an infinite recursion that overflows the stack.
                PermissionSet.s_fullTrust.Assert();
                RuntimeTypeHandle rth = rmh.GetDeclaringType();
                return(System.RuntimeType.GetMethodBase(rth, rmh) as MethodInfo);
#if _DEBUG
            }
            catch(Exception)
            {
                return null;
            }
#endif
        }

Usage Example

Example #1
0
        internal static Exception MakeSecurityException(AssemblyName asmName, Evidence asmEvidence, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, object demand, IPermission permThatFailed)
        {
            HostProtectionPermission protectionPermission = permThatFailed as HostProtectionPermission;

            if (protectionPermission != null)
            {
                return((Exception) new HostProtectionException(SecurityException.GetResString("HostProtection_HostProtection"), HostProtectionPermission.protectedResources, protectionPermission.Resources));
            }
            string     message = "";
            MethodInfo method  = (MethodInfo)null;

            try
            {
                message = granted != null || refused != null || demand != null ? (demand == null || !(demand is IPermission) ? (permThatFailed == null ? SecurityException.GetResString("Security_GenericNoType") : string.Format((IFormatProvider)CultureInfo.InvariantCulture, SecurityException.GetResString("Security_Generic"), (object)permThatFailed.GetType().AssemblyQualifiedName)) : string.Format((IFormatProvider)CultureInfo.InvariantCulture, SecurityException.GetResString("Security_Generic"), (object)demand.GetType().AssemblyQualifiedName)) : SecurityException.GetResString("Security_NoAPTCA");
                method  = SecurityRuntime.GetMethodInfo(rmh);
            }
            catch (Exception ex)
            {
                if (ex is ThreadAbortException)
                {
                    throw;
                }
            }
            return((Exception) new SecurityException(message, asmName, granted, refused, method, action, demand, permThatFailed, asmEvidence));
        }
All Usage Examples Of System.Security.SecurityRuntime::GetMethodInfo