Oct 22, 2010 at 10:21 PM
Edited Oct 22, 2010 at 10:21 PM
Hello. I've created an application based on Flee and I really like this library, but there is one exception.
Example source code:
ExpressionContext context = new ExpressionContext();
//"m" means decimal
context.Variables["a"] = 10m;
context.Variables["b"] = 20m;
IDynamicExpression eDynamic = context.CompileDynamic("a && b");
bool result = (bool)eDynamic.Evaluate();
I get an exception "AndOrElement: Operation 'And' is not defined for types 'Decimal' and 'Decimal'".
How can I fix it?
I've tried to modify source code of Flee, but I'm new to Visual Basic. I found a place where the exception is thrown, but I couldn't make it work.
I changed the method GetResultType in AndOr.vb file to:
Protected Overrides Function GetResultType(ByVal leftType As System.Type, ByVal rightType As System.Type) As System.Type
Dim bitwiseOpType As Type = Utility.GetBitwiseOpType(leftType, rightType)
If Not bitwiseOpType Is Nothing Then
ElseIf Me.AreBothChildrenOfType(GetType(Boolean)) Then
but then I get an exception in Evaluate method in Expression.vb file:
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
at Flee Expression(Object , ExpressionContext , VariableCollection )
at Ciloci.Flee.Expression`1.Evaluate() in D:\Dokumenty\Piotrek\Ikosoft\Flee\src\Lib\InternalTypes\Expression.vb:line 154
at ConsoleTester.Module1.Main() in D:\Dokumenty\Piotrek\Ikosoft\Flee\src\ConsoleTester\Module1.vb:line 23
It seems that MyLeftChild and MyRightChild should be converted to Boolean, but how?
Please help. Thank you for any working solutions ASAP.