I'm just starting to use Jint 2.0 in my c# application. However I cannot seem to be able to retrieve a value from within Jint.
Even with the example code provided:
var engine = new Jint.Engine();
engine.Execute(@" function add(x, y) { return x + y; } var z = add(3, 2);");
var z = engine.GetValue("z");
Console.WriteLine(z); // -> 5
The line var z = engine.GetValue("z");
is throwing an InvalidCastException (specified cast is not valid)
Considering this is the example code, is there something simple I'm missing?
UPDATE: I was able to get it to work if I changed 'GetValue' to GetGlobalValue'. I would still like to know why this is, so I'm leaving the question open.