Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Edited Issue: Check for DispId attribute when looking for default property [74]

We are using ClearScript in our application as a replacement for the MS Script Control (to enable users to run custom scripts interfacing with an application-provided object), and we've encountered an issue involving legacy behaviour with retrieving default property values, where those objects are .NET objects.

The situation we encountered involved VBScript accessing a DAO-like object:

Something = rs.Fields("something")

where rs.Fields is a method returning an IEnumerable object (a "Fields" object). The object returned by the Fields object (the "Field" object) has a default property as so:

public object Value
get { .... }
set { .... }

The enumeration is working fine, but the default property would not be identified as such. The VBScript engine was actually looking for "[DISPID=0]", but ClearScript wasn't checking the DispId attribute. The attached patch adds support to check for the DispId attribute.

The attached patch fixes the getting; setting unfortunately still doesn't work with this fix, but we worked around that in our application. (If you have any idea how to fix it in ClearScript as well though, I'm sure that would be useful!)

Hope this is useful, and that my fix is correct!

Thanks, Owen.

Viewing all articles
Browse latest Browse all 2297