OnlyStaticMethodsHaveNullInstance() static private méthode

ArgumentException with message like "Static method requires null instance, non-static method requires non-null instance."
static private OnlyStaticMethodsHaveNullInstance ( ) : Exception
Résultat Exception
        private static void ValidateAccessor(Expression instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection <Expression> arguments)
        {
            ContractUtils.RequiresNotNull(arguments, "arguments");

            ValidateMethodInfo(method);
            if ((method.CallingConvention & CallingConventions.VarArgs) != 0)
            {
                throw Error.AccessorsCannotHaveVarArgs();
            }

            if (method.IsStatic)
            {
                if (instance != null)
                {
                    throw Error.OnlyStaticMethodsHaveNullInstance();
                }
            }
            else
            {
                if (instance == null)
                {
                    throw Error.OnlyStaticMethodsHaveNullInstance();
                }

                RequiresCanRead(instance, "instance");
                ValidateCallInstanceType(instance.Type, method);
            }

            ValidateAccessorArgumentTypes(method, indexes, ref arguments);
        }