This project has moved and is read-only. For the latest updates, please go here.


Feb 11, 2014 at 10:24 AM
Hello, first of all i´d like to say you thank for share your proyect.

I´m testing the library and I´ve found some unexpected problems:
  • If I try to EVAL next expressions:
    Replace "." by empty string --> '1000.00'.Replace('.', '')
    Replace "," by "." --> '1,000.00'.Replace(',', '.')
    I get next error: Exception HRESULT: 0x80131047.
  • If I try to EVAL next expresion:
    DateTime.ParseExact('02/11/2014 09:14', 'M/d/yyyy hh:mm', CultureInfo.InvariantCulture).ToString('dd/MM/yyyy HH:MM:SS')
I get the same error

Do you think it is a bug in the library or there exists some error in how I use the library?

Thanks in advance!
Feb 12, 2014 at 3:17 AM
Edited Feb 12, 2014 at 3:58 AM

Not sure what the problem is as I was unable to replicate the issue. Here is my code below:

        var c = new CompiledExpression();
        c.StringToParse = "'1000.00'.Replace('.', '')";
        var e = c.Eval(); // returns 100000

        c.StringToParse = "'1,000.00'.Replace(',', '.')";
        e = c.Eval(); // returns 1.000.00

        // Remember, you have to register types to use them in your expression.
        // DateTime is included in the DefaultTypes but CultureInfo is not
        c.RegisterType("CultureInfo", typeof(CultureInfo));

        c.StringToParse = "DateTime.ParseExact('02/11/2014 09:14', 'M/d/yyyy hh:mm', CultureInfo.InvariantCulture).ToString('dd/MM/yyyy HH:MM:SS')";
        e = c.Eval(); // returns  11/02/2014 09:02:SS

Looks like it should be "dd/MM/yyyy HH:mm:ss"

Also, I did not get any error "HRESULT: 0x80131047" at all. Try getting the latest source code.
Feb 14, 2014 at 9:42 AM
Edited Feb 14, 2014 at 11:34 AM

I have the same problem with a comma in the expression.

This sample works fine:
            string parsestr = "string.IsNullOrEmpty('asdf')";
            var p = new CompiledExpression(parsestr);
            Console.WriteLine("Result: {0}", p.Eval());
But this sample (with a comma in the string) throws an exception:
            string parsestr = "string.IsNullOrEmpty('asdf,')";
            var p = new CompiledExpression(parsestr);
            Console.WriteLine("Result: {0}", p.Eval());
Exception message is "Parser error at position 20: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)".
I used the latest version of Expression Evaluator (1.0.2).

Hope you can help,

Now I tried the latest source code and it seems that the problem is solved.
Feb 15, 2014 at 10:39 PM
So its seems the bug was in the 1.0.2 build that is available for download. Sorry about that! I will update the package with a more recent build.