Hi all, I was hoping you could help me with a little issue we seem to be having.
At the moment our current solution is to dispose and re-instantiate the engine for each script, which is increasing our run time by a great deal (We're running about 2000 scripts at the moment and it's taking about 5x longer than it did prior to V8Engine).
The ideal solution would be some kind of V8Engine.Clear() method that would refresh the environment so that each execution was in it's own 'isolated' environment. Otherwise we run into issues where variables share names between scripts and it shows an error
when the second script tries to 're-declare' it.
Below is our current implementation, sorry if my explanation isnt very clear, if you have any questions feel free to ask
public string Execute(string script)
string result = "";
// EVALUATE THE SCRIPT
//You have to create the engine again before each script, or you run into the issue of it 'remembering'
//which variables have been declared in previous scripts
//Create the V8Engine and dispose when done
using (m_engine = new V8Engine())
//Set the Lookup instance as a global object so that the JS code in the V8.Net wrapper can access it
m_engine.GlobalObject.SetProperty("Lookup", m_lookup, null, true, ScriptMemberSecurity.Permanent);
//Execute the script
result = m_engine.Execute(script);
catch (Exception ex)
// V8.NET error?
if (ex.Source.CompareTo("V8.Net") == 0)
// Yes, turn it into a Race V8 Exception to avoid a stack trace dump.
// Not a V8 error, so just re-throw exception.