System.Linq.Expressions.Error.ExpressionTypeDoesNotMatchConstructorParameter C# (CSharp) Method

ExpressionTypeDoesNotMatchConstructorParameter() static private method

ArgumentException with message like "Expression of type '{0}' cannot be used for constructor parameter of type '{1}'"
static private ExpressionTypeDoesNotMatchConstructorParameter ( object p0, object p1, string paramName, int index ) : Exception
p0 object
p1 object
paramName string
index int
return System.Exception
        internal static Exception ExpressionTypeDoesNotMatchConstructorParameter(object p0, object p1, string paramName, int index)
        {
            return Dynamic.Utils.Error.ExpressionTypeDoesNotMatchConstructorParameter(p0, p1, paramName, index);
        }
        /// <summary>

Usage Example

        private static Expression ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi)
        {
            RequiresCanRead(arg, "arguments");
            Type pType = pi.ParameterType;

            if (pType.IsByRef)
            {
                pType = pType.GetElementType();
            }
            TypeUtils.ValidateType(pType);
            if (!TypeUtils.AreReferenceAssignable(pType, arg.Type))
            {
                if (TypeUtils.IsSameOrSubclass(typeof(Expression), pType) && pType.IsAssignableFrom(arg.GetType()))
                {
                    arg = Expression.Quote(arg);
                }
                else
                {
                    // TODO: this is for LinqV1 compat, can we just have one exception?
                    switch (nodeKind)
                    {
                    case ExpressionType.New:
                        throw Error.ExpressionTypeDoesNotMatchConstructorParameter(arg.Type, pType);

                    case ExpressionType.Invoke:
                        throw Error.ExpressionTypeDoesNotMatchParameter(arg.Type, pType);

                    case ExpressionType.Dynamic:
                    case ExpressionType.Call:
                        throw Error.ExpressionTypeDoesNotMatchMethodParameter(arg.Type, pType, method);

                    default:
                        throw Assert.Unreachable;
                    }
                }
            }
            return(arg);
        }
All Usage Examples Of System.Linq.Expressions.Error::ExpressionTypeDoesNotMatchConstructorParameter
Error