Weird Exception with expressions using decimal

Sep 22, 2010 at 9:27 PM


The following code throws a "Operator '/' can't be applied to operands of types 'double' and 'decimal'" exception and I cannot work out for the life of me why.
The native c# throws no exception.
Also if I change the definition of a  & b to double it works.... Any Ideas???
void Test()
   decimal a = 20;
   decimal b = 50;
   Expression ex = new Expression("a / b * 100", EvaluateOptions.IgnoreCase | EvaluateOptions.NoCache);
   ex.EvaluateParameter += delegate(string name, ParameterArgs arg)
      if (name == "a")
        arg.Result = a;
      else if (name == "b")
        arg.Result = b;
   MessageBox.Show((a / b * 100).ToString());


Sep 22, 2010 at 9:48 PM

Are you using the latest available source code ? I can't reproduce this and I have done some changes recently on the topic.


Sep 22, 2010 at 10:50 PM

I just downloaded them.

I see I now need to include Antlr3.runtime.dll in my project? 

I get the error message: "Error 1 Assembly generation failed -- Referenced assembly 'NCalc' does not have a strong name"

Sep 22, 2010 at 11:11 PM

I need to create a release then. It includes assembly merging, and also strong signing. Give me some time for it.

Sep 23, 2010 at 12:26 AM

No problem. Thanks for your great work!

Sep 23, 2010 at 1:03 AM


Sep 23, 2010 at 5:01 PM

Excellent. That seems to solve the problem!

But...... If I change the expression to: "a / b * 100.00"

I get the same error?