Hello,
Yes, ClearScript provides
However, there are some considerations. First, the above code works only if the type resides in
However, you might want to avoid doing so. Identifying an assembly based on a short name like "System.Core" requires an expensive brute-force search that incurs a large one-time performance hit (the results of the search are saved in a file for subsequent reuse).
Our recommended approach is to load the type manually via
Good luck!
Yes, ClearScript provides
AddHostType
overloads that let you specify the type by name. For example:jse.AddHostType("Random", "System.Random");
mscorlib
or in the currently executing assembly. For other types, you can specify the assembly:engine.AddHostType("Enumerable", "System.Linq.Enumerable", "System.Core");
Our recommended approach is to load the type manually via
Type.GetType
. For non-mscorlib
types this does require an assembly-qualified name:engine.AddHostType("Enumerable", Type.GetType("System.Linq.Enumerable, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));