This project has moved and is read-only. For the latest updates, please go here.

Cannot set a string as host object?

Feb 5, 2014 at 9:55 AM

I may be missing something obvious, but this call fails on a V8ScriptEngine:
engine.AddHostObject("test", "hello");
Feeling like a noob... :)
Thanks for your help!
Feb 5, 2014 at 11:48 AM

That's correct; ScriptEngine.AddHostObject() does not work with simple values like strings and numbers.

Instead, you can do any of the following:
engine.Script.test = "hello";
engine.Script["test"] = "hello";
engine.Execute("test = 'hello'");