This project is read-only.


Sep 24, 2009 at 4:17 PM


Is there any example how to create compoundable binary binder expression which can throw an exception. I tried to return Expression.Throw but DLR complains with

System.InvalidCastException: The result type 'System.Void' of the dynamic binding produced by binder 'MyBinaryOperationBinder' is not compatible with the result type 'System.Object' expected by the call site.

which kind of makes a sense as throw is of type void. Any hints how to throw and return correct binary expression type at same time ?


Sep 24, 2009 at 4:47 PM

You can change the type of the throw expression by specifying it as a second argument:

Expression.Throw(value, typeof(object))


Sep 24, 2009 at 5:34 PM

Thanks, exactly what I needed.