This project is read-only.

Accessing properties of Dynamic Object in VBScript

May 18, 2010 at 7:08 AM

I am currently using the ASPCompiler project to execute VBScript in my application. Below is one scenario that I want to handle. I have a complex object that represents the elements of a page such as TextBox, Lable etc. This object is passed into the ScriptScope as a variable called fcBusinessEvent and in the script I have some fairly complex code like below:

Set grp = fcBusinessEvent.ObjectGroups.Item(\"0\")

Set grpStock = fcBusinessEvent.ObjectGroups.NamedItem(\"PR1010Stock\")

Set grpNonStock = fcBusinessEvent.ObjectGroups.NamedItem(\"PR1020NonStock\")

grpStock.Visible = False

grpNonStock.Visible = False

grp.Item(\"PR10140StockTotal\").Options.Item(\"Visible\") = False

grp.Item(\"PR10150NonStockTotal\").Options.Item(\"Visible\") = False

when I try executing this code I get error "Can't bind member invoke ObjectGroups.Item(System.Dynamic.DynamicMetaObject[]).

If you can give me some pointers regarding how to resolve this issue.

Jun 29, 2011 at 8:56 PM

Same here, have you been able to fix this issue finally?

Jun 29, 2011 at 9:39 PM

I have not fixed it. Somehow this one slipped through my radar screen. I will try to recreate this scenario and fix it.

Jun 30, 2011 at 1:12 PM

Hi dotneteer,

   I have finally been able to map my issue to an parameter type mismatch in the script, therefore I believe that there is no "actual" issue.

   However, I could suggest mapping such errors to a more meaningful exception, to simplify debugging ( I suspect this type of error could happen a lot in the future).



Jun 30, 2011 at 3:53 PM

Does your script run in VBScript? If yes, it is probably doing some automatic type conversion. Let me know what you had to do to fix your script so that I can try to improve the compatibility. Thanks.

Jun 30, 2011 at 4:57 PM

Yes, script used to run using Microsoft Script Control (currently porting from it to DLR).

Basically, all the little type conversions such as Integer to String that used to be done automatically are not anymore.

Right now, I can't really fix the script (outside my control), but I'm adapting my objects by having dynamic parameters and doing some of the basic conversion in the method bodies (not ideal, but works).

Jun 30, 2011 at 4:57 PM

Let me know if you need any more details, I'd be glad to help.

Jun 30, 2011 at 6:04 PM

Marcus, thank you for your help. I will look into the automatic string to integer as well as integer to string conversion. If you encounter any other types automatic conversion, please let me know. Thanks.