Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: access indexer of a hosted object


I have the following problem with a default property indexer (from DataRow dotnet Framework class).

In C# :
scriptEngine.AddHostObject("DotNet", new HostTypeCollection("mscorlib", "System.Core", "System.Data"));
In my Javascript :
var dt = new DotNet.System.Data.DataTable("testDataTable");
var dr = dt.NewRow();
dr('Col1') = 'Test1'; // Works only with JScriptEngine, not with  V8ScriptEngine :-(
dr.set('Col1','Test1'); // Does not work :-(
1°/ Like you said in previous post, JScriptEngine & V8ScriptEngine are different, so dr('Col1') = 'Test1'; run only on JScriptEngine. For now, I was thinking using V8ScriptEngine, because error handling seems to be better.
2°/ The 2nd code you said in previous code dr.set('Col1','Test1'); does not run. Perharps because it's a default property indexer (this[]) ?

Do you have a solution or a workaround for this problem please ?

Thanks for advance.


Viewing all articles
Browse latest Browse all 2297