zzzprojects / Eval-Expression.NET

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

NullReferenceException #14

Closed Alphaquest2005 closed 6 years ago

Alphaquest2005 commented 7 years ago

When i try to execute the following code i get a 'Object reference not set to an instance of an object.'

var evalContext = new EvalContext();
evalContext.RegisterDomainAssemblies();
var body = @" new DomainMessage(""UserValidated"",cp?.Messages[""ValidatedUser""]?.Entity,
                                new StateEventInfo(cp?.Actor?.Process?.Id, 
Context.Domain.Events.DomainEventPublished),
                                cp.Actor.Process, cp.Actor.Source)";
var res = evalContext.Compile<Func<IComplexEventParameters, IProcessSystemMessage>>(body, "cp");

The parameter contains dynamic types is that the cause?

JonathanMagnan commented 7 years ago

Hello @Alphaquest2005,

Yes, this could be the cause since your expression is complex.

We support dynamic types but they may have case that we might have forgotten.

Do you think you could send us a full example that doesn't work to make sure on our side we try to fix the right issue?

Best Regards,

Jonathan

JonathanMagnan commented 6 years ago

Hello @Alphaquest2005 ,

Do you think you will be able to find time to provide us an example?

In your current example, I'm not sure which field or property is currently dynamic types or real types.

Best Regards,

Jonathan

Alphaquest2005 commented 6 years ago

Hi thank for following up… Fact is I just refactored out the dynamic type and replaced it with dictionary… to match the rest of static c#.... So far so good…

Thanks any ways

joseph

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10


From: Jonathan Magnan notifications@github.com Sent: Sunday, November 26, 2017 10:13:02 PM To: zzzprojects/Eval-Expression.NET Cc: Alphaquest2005; Mention Subject: Re: [zzzprojects/Eval-Expression.NET] NullReferenceException (#14)

Hello @Alphaquest2005https://github.com/alphaquest2005 ,

Do you think you will be able to find time to provide us an example?

In your current example, I'm not sure which field or property is currently dynamic types or real types.

Best Regards,

Jonathan

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/zzzprojects/Eval-Expression.NET/issues/14#issuecomment-347061254, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AVMPZcWLtv8ndw_3K670hSWPAZmDCKGmks5s6hqtgaJpZM4QKj31.

JonathanMagnan commented 6 years ago

Hello @Alphaquest2005 ,

We will close this issue seem there is no so much we can do currently since you look to have fixed it on your side.

Feel free to reopen if I shouldn't have closed it.

Best Regards,

Jonathan