The type initializer for 'Microsoft.ClearScript.Util.AssemblyHelpers' threw an exception

Feb 13, 2014 at 12:13 PM
hello, i have this script:
engine.AddHostObject("lib", new HostTypeCollection("mscorlib", "System.Core"));
this script will be ok in a ConsoleApplication.exe. but if i write this code in mvc and deploy to iis7.5/win2008r2, this will throw an exception:
The type initializer for 'Microsoft.ClearScript.Util.AssemblyHelpers' threw an exception.

System.String GetFullAssemblyName(System.String)
at Microsoft.ClearScript.Util.AssemblyHelpers.GetFullAssemblyName(String name) at Microsoft.ClearScript.HostTypeCollection.AddAssembly(String assemblyName) at System.Array.ForEach[T](T[] array, Action`1 action) at MyEngine.InitScriptEngin() in MyEngine.cs:line 80

It maybe something about "access right" or can't find the system dll problem, but i don't know how to fix it, please help.

best&regards
Coordinator
Feb 13, 2014 at 1:28 PM
Greetings zestyzeng!

We believe this issue is fixed in ClearScript 5.3.11. Can you give that version a try?

If not, you can work around this issue (and slightly improve your application's performance) by specifying preloaded assemblies when constructing your host type collection:
var mscorlib = typeof(System.String).Assembly;
var systemCore = typeof(System.Linq.Enumerable).Assembly;
engine.AddHostObject("lib", new HostTypeCollection(mscorlib, systemCore));
Good luck!
Feb 14, 2014 at 1:59 AM
Dear ClearScript.

Two solutions are feasible in my project.

Thank you very much.


ps. I'm using VS2010, I must find the *.dll from the nuget or otherway. would you please maintain a official package?