I get a exception if I try to use GetCompletionValue
with Invoker
.
How can i execute the run
function with IIFE lexical scope?
Javascript:
(function(){
function run() {
logger('teste logger');
var file = new System.IO.StreamWriter('log.txt');
file.WriteLine('Write file test');
file.Dispose();
}
return {
'run': run
}
})();
My Invoker:
public void Execute(string code, string functionName)
{
_engine.Execute(code).GetCompletionValue();
_engine.Invoke(functionName); // -- run function
}
Error:
Exception has occurred: CLR/System.ArgumentException
An exception of type 'System.ArgumentException' occurred in Jint.dll but was not handled in user code: 'Can only invoke functions'
at Jint.Engine.Invoke(JsValue value, Object thisObj, Object[] arguments)
at Jint.Engine.Invoke(String propertyName, Object thisObj, Object[] arguments)
at Jint.Engine.Invoke(String propertyName, Object[] arguments)