zzzprojects / Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://eval-expression.net/
Other
449 stars 86 forks source link

error running the ExpandoObject example #17

Closed lynnmiller closed 6 years ago

lynnmiller commented 6 years ago

I am trying to get the examples running from your website. I have been successful getting 3 of 4 working. The only one not working is the ExpandoObject example.

Here is my code:

        // using Z.Expressions; // Don't forget to include this.
        int result1 = Eval.Execute<int>("X + Y", new { X = 1, Y = 2 });
        Console.WriteLine(result1);

        // using Z.Expressions; // Don't forget to include this.
        int result2 = Eval.Execute<int>("{0} + {1}", 1, 2);
        Console.WriteLine(result2);

        // using Z.Expressions; // Don't forget to include this.
        dynamic expandoObject = new ExpandoObject();
        expandoObject.X = 1;
        expandoObject.Y = 2;
        int result3 = Eval.Execute<int>("X + Y", expandoObject);
        Console.WriteLine(result3);

        // using Z.Expressions; // Don't forget to include this.
        string s = "X + Y";
        int result4 = s.Execute<int>(new { X = 1, Y = 2 });
        Console.WriteLine(result4);

        Console.ReadKey();

Here is my error:

-System.InvalidOperationException: 'The binary operator Add is not defined for the types 'System.Object' and 'System.Object'.'

I am using the evaluation version 2.4.3

JonathanMagnan commented 6 years ago

Hello @lynnmiller ,

Thank you for reporting.

We successfully reproduced the issue. We will try to fix it tomorrow.

Best Regards,

Jonathan

lynnmiller commented 6 years ago

Thanks!

JonathanMagnan commented 6 years ago

Hello @lynnmiller ,

Sorry for the delay, it took us a little bit more time than expected to fix this one.

The v2.4.4 has been released.

Let me know if you can now run example successfully.

Best Regards,

Jonathan

lynnmiller commented 6 years ago

No problem about the delay. I tested it and it works. Thanks!