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

InvalidProgramException .NET 5? #103

Closed mthrift2100 closed 3 years ago

mthrift2100 commented 3 years ago

I'm attempting to implement Z.Expressions within a .NET 5 project. I believe .NET 5 projects can target .NET Standard projects. But I am getting a InvalidProgramException when attempting to run an Eval.Execute<decimal>("a*b", new decimal(500.000), newdecimal(.75))`

mthrift2100 commented 3 years ago

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Z.Expressions.EvalManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Z.Expressions.EvalContext' threw an exception. ---> System.InvalidProgramException at Z.Expressions.EvalContext..cctor() --- End of inner exception stack trace --- at Z.Expressions.EvalManager..cctor() --- End of inner exception stack trace ---

JonathanMagnan commented 3 years ago

Hello @mthrift2100 ,

Our library support without problem .NET 5.

As explained by email, this issue happens due to the fact you use Blazor and probably try to use our library on the Client Side which doesn't support the full .NET Framework.

The WebAssembly (or whatever how it works in blazor) is limited and doesn't allow what is required by our library on the client-side such as compiling lambda expression and will probably never support it.

Let me know if that answers correctly to your question.

Best Regards,

Jon