System.Reflection.RuntimeMethodInfo.ThrowNoInvokeException C# (CSharp) Method

ThrowNoInvokeException() private method

private ThrowNoInvokeException ( ) : void
return void
        private void ThrowNoInvokeException()
        {
            // method is ReflectionOnly
            Type declaringType = DeclaringType;
            if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
                throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyInvoke"));
                       
            // method is on a class that contains stack pointers
            if (DeclaringType.GetRootElementType() == typeof(ArgIterator))
                throw new NotSupportedException();
            
            // method is vararg
            else if ((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
                throw new NotSupportedException();
                        
            // method is generic or on a generic class
            else if (DeclaringType.ContainsGenericParameters || ContainsGenericParameters)
                throw new InvalidOperationException(Environment.GetResourceString ("Arg_UnboundGenParam"));
            
            // method is abstract class
            else if (IsAbstract)
                throw new MemberAccessException();
            
            // ByRef return are not allowed in reflection
            else if (ReturnType.IsByRef)
                throw new NotSupportedException(Environment.GetResourceString("NotSupported_ByRefReturn"));

            throw new TargetException();
        }