Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Enriching an object in script = object disposed exception?

0
0
Hi Tony,

Your code above creates a property (named "someNewProperty") whose value is a script object.

Fundamentally, a script object is not a standalone object; it can be considered a sort of reference into a script engine's in-memory state. Accessing the properties of a script object requires the services of the script engine that created it.

In your scenario, consider using a host object instead. For example:
// C#
engine.AddHostType("ExpandoObject", typeof(ExpandoObject));
and then:
// JavaScript
theObject.someNewProperty = new ExpandoObject();
theObject.someNewProperty.innerProperty1 = 10;
theObject.someNewProperty.innerProperty2 = 'Hello world';
Good luck!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images