You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An expression like "foo" & SomeVar fails when SomeVar is not a reference type. When Parse() is called a System.ArgumentException is raised stating that int cannot be used for object arguments. I assume the value needs to be manually boxed before being passed to string.Concat. If I create an expression manually I get the same error. When I firstly convert the value to object, the Concat works just fine.
2. Exception
Unhandled exception. System.ArgumentException: Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object' of method 'System.String Concat(System.Object, System.Object)' (Parameter 'arg1')
at System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1)
at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
at System.Linq.Dynamic.Core.Parser.ExpressionHelper.GenerateStaticMethodCall(String methodName, Expression left, Expression right)
at System.Linq.Dynamic.Core.Parser.ExpressionHelper.GenerateStringConcat(Expression left, Expression right)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAndOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLambdaOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNullCoalescingOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseConditionalOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.Parse(Type resultType, Boolean createParameterCtor)
at TypeBuilderWithExpression.Program.Main(String[] args)
1. Description
An expression like
"foo" & SomeVar
fails whenSomeVar
is not a reference type. When Parse() is called a System.ArgumentException is raised stating thatint
cannot be used forobject
arguments. I assume the value needs to be manually boxed before being passed to string.Concat. If I create an expression manually I get the same error. When I firstly convert the value to object, the Concat works just fine.2. Exception
3. Fiddle or Project
If you are able,
Provide a Fiddle that reproduce the issue: https://dotnetfiddle.net/25Vjsn
4. Any further technical details
This doesn't work:
But this does:
The text was updated successfully, but these errors were encountered: