1

Closed

Exception An expression of type 'System.Object' cannot be used to initialize an array of type 'System.Object[]

description

The class SerializableExpressionVisitor throw a TargetInvocationException with innerException message is
An expression of type 'System.Object' cannot be used to initialize an array of type 'System.Object[]
when processing the following lines :
 
        else if( expression is SerializableLambdaExpression ) {
            if( expression is SerializableExpressionTyped ) {
                MethodInfo executeMethod = GetType().GetMethod( "VisitSerializableExpressionTyped", BindingFlags.NonPublic | BindingFlags.Instance );
                MethodInfo genericExecuteMethod = executeMethod.MakeGenericMethod( new Type[] { (Type) expression.Type.GetClrVersion() } );
                returnValue = (Expression) genericExecuteMethod.Invoke( this, new object[] { expression } ); <=== RAISE
            }
            else {
                returnValue = VisitSerializableLambdaExpression( expression as SerializableLambdaExpression );
            }
        }
 
when expression equals : { => new [] {Convert(.Key), Convert(Count())}}
Closed Aug 28, 2009 at 8:14 PM by Winston_Smith
Is resolved and tested with the Unit-Test Array_01_Static:var employeesQuery = from e in companyExampleContext.Employeesselect new { Name = e.Name, StaticArray = new[] { "oak", "fir", "spruce", "alder" } };Assert.AreEqual(13, employeesQuery.Count());Assert.AreEqual("oak", employeesQuery.ToList()[1].StaticArray[0]);

comments