Closed rogerfar closed 6 years ago
Hello @yesman85 ,
Did you register your ComplexType
via RegisterType
or RegisterAssembly` ? I tried some very basic scenario which seemed to work.
public class BaseType
{
}
public class ComplexType : BaseType
{
public int ColumnInt { get; set; }
}
EvalManager.DefaultContext.RegisterType(typeof(ComplexType));
var item = Eval.Execute<ComplexType>("var test = new ComplexType();");
var list = Eval.Execute<List<ComplexType>>("var list = new List<ComplexType>();");
Yes, if I execute both lines in a single Execute it will break on the 2nd line, not the first one, indicating that the type is actually found.
Strange, it seems to work on our side even in a single execute
Do you think you could try the following code?
public class BaseType
{
}
public class ComplexType : BaseType
{
public int ColumnInt { get; set; }
}
EvalManager.DefaultContext.RegisterType(typeof(ComplexType));
var test = Eval.Execute(@"
var test= new ComplexType();
var list = new List<ComplexType>();
");
It works, BUT when I add: EvalManager.DefaultContext.RegisterDomainAssemblies();
it stopped working, even when I remove EvalManager.DefaultContext.RegisterType(typeof(ComplexType));
.
I also noticed that my complex type is a partial class, maybe that's the culprit?
Do you think you could provide a small example with this issue? By example in a new console application?
It will make easier on our side to fix it than trying to reproduce the problem.
It seems to work on partial
class and with RegisterDomainAssemblies
.
I tried it in a separate app but it worked then, but now I found out that it's not the complex type that's the issue but the List
When I do var list = new System.Collections.Generic.List<ComplexType>();
it works, so there must be another assembly with the name List somewhere, although Visual Studio is not suggesting there is.
Hello @yesman85 ,
Thank a lot,
We released the v2.4.2 which blacklist the class List
when registering type via RegisterDomainAssemblies
. A better solution will need to be found later.
Let me know if your expression can now work correctly.
Best Regards,
Jonathan
Yes it works good now! Thanks.
When trying to execute the following code:
ComplexType is just a class in this example.
it fails at the 2nd line with the message:
Oops! The type could not be found. Only common type are registered by default. Make sure the type you are using is registered: https://github.com/zzzprojects/Eval-Expression.NET/wiki/EvalContext-Register-&-Unregister