Passing complex object to Script Control

May 19, 2010 at 2:13 AM

We need to pass a complex object to the script control so that the VBScript can be used to set various properties on these objects passed to the script control. When I execute the script I get the following error: "Can't bind member invoke ObjectGroups.Item(System.Dynamic.DynamicMetaObject[])". I wanted to find out if I need to implement theIDynamicMetaObjectProvider interface on all the objects that I pass into the Script Control so that the script can set the properties  at runtime. 

 

Coordinator
May 19, 2010 at 4:59 AM
No. You do not need to implement IDynamicMetaObjectProvider.
You should be able to just add the object to the scope and VBScript.net compiler can bind to the methods. This in fact how we feed request, response objects to ASPClassicCompiler.
In earlier post, you asked why you were not able to assign to the names in the scope. The reason it did not work is that I disabled the assignment to names in the scope to avoid objects like Request/Response from being swapped. To pass value in and out, you can store an object into the scope and call methods of your object to store values for you.
Li

From: [email removed]
Sent: Tuesday, May 18, 2010 6:13 PM
To: [email removed]
Subject: Passing complex object to Script Control [aspclassiccompiler:213103]

From: manthangogari

We need to pass a complex object to the script control so that the VBScript can be used to set various properties on these objects passed to the script control. When I execute the script I get the following error: "Can't bind member invoke ObjectGroups.Item(System.Dynamic.DynamicMetaObject[])". I wanted to find out if I need to implement theIDynamicMetaObjectProvider interface on all the objects that I pass into the Script Control so that the script can set the properties at runtime.

May 20, 2010 at 1:23 AM
Hello there,

Thanks for the clarification. One thing that I have noticed one thing if I have a Object that is inherting from System objects say for example a SortedList and in my script I do the following:
Set grp = MyObject.Item("0")
The script control throws the error as Can't bind member Invoke MyObject.Item(System.Dynamic.DynamicMetaObject[]) now in that case do I have to override the SortedList.Item method in the MyObject class that Inherits from the SortedList. 

Hoping to hear from you soon.


On Wed, May 19, 2010 at 1:59 PM, dotneteer <notifications@codeplex.com> wrote:

From: dotneteer

No. You do not need to implement IDynamicMetaObjectProvider.
You should be able to just add the object to the scope and VBScript.net compiler can bind to the methods. This in fact how we feed request, response objects to ASPClassicCompiler.
In earlier post, you asked why you were not able to assign to the names in the scope. The reason it did not work is that I disabled the assignment to names in the scope to avoid objects like Request/Response from being swapped. To pass value in and out, you can store an object into the scope and call methods of your object to store values for you.
Li

From: [email removed]
Sent: Tuesday, May 18, 2010 6:13 PM
To: [email removed]
Subject: Passing complex object to Script Control [aspclassiccompiler:213103]

From: manthangogari

We need to pass a complex object to the script control so that the VBScript can be used to set various properties on these objects passed to the script control. When I execute the script I get the following error: "Can't bind member invoke ObjectGroups.Item(System.Dynamic.DynamicMetaObject[])". I wanted to find out if I need to implement theIDynamicMetaObjectProvider interface on all the objects that I pass into the Script Control so that the script can set the properties at runtime.

Read the full discussion online.

To add a post to this discussion, reply to this email (aspclassiccompiler@discussions.codeplex.com)

To start a new discussion for this project, email aspclassiccompiler@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Sincerely,

Manthan Gogari
May 20, 2010 at 1:26 AM
I had mentioned Item is a method which it is not it is a property on the SortedList Class

On Thu, May 20, 2010 at 10:23 AM, Manthan Gogri <manthan.gogri@gmail.com> wrote:
Hello there,

Thanks for the clarification. One thing that I have noticed one thing if I have a Object that is inherting from System objects say for example a SortedList and in my script I do the following:
Set grp = MyObject.Item("0")
The script control throws the error as Can't bind member Invoke MyObject.Item(System.Dynamic.DynamicMetaObject[]) now in that case do I have to override the SortedList.Item method in the MyObject class that Inherits from the SortedList. 

Hoping to hear from you soon.


On Wed, May 19, 2010 at 1:59 PM, dotneteer <notifications@codeplex.com> wrote:

From: dotneteer

No. You do not need to implement IDynamicMetaObjectProvider.
You should be able to just add the object to the scope and VBScript.net compiler can bind to the methods. This in fact how we feed request, response objects to ASPClassicCompiler.
In earlier post, you asked why you were not able to assign to the names in the scope. The reason it did not work is that I disabled the assignment to names in the scope to avoid objects like Request/Response from being swapped. To pass value in and out, you can store an object into the scope and call methods of your object to store values for you.
Li

From: [email removed]
Sent: Tuesday, May 18, 2010 6:13 PM
To: [email removed]
Subject: Passing complex object to Script Control [aspclassiccompiler:213103]

From: manthangogari

We need to pass a complex object to the script control so that the VBScript can be used to set various properties on these objects passed to the script control. When I execute the script I get the following error: "Can't bind member invoke ObjectGroups.Item(System.Dynamic.DynamicMetaObject[])". I wanted to find out if I need to implement theIDynamicMetaObjectProvider interface on all the objects that I pass into the Script Control so that the script can set the properties at runtime.

Read the full discussion online.

To add a post to this discussion, reply to this email (aspclassiccompiler@discussions.codeplex.com)

To start a new discussion for this project, email aspclassiccompiler@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Sincerely,

Manthan Gogari



--
Sincerely,

Manthan Gogari
May 20, 2010 at 2:22 AM

The issue that I am having is that the VBScript.net does not recognize the SortedList.Item property when I have overriden it in my child class. 

What i have done is I have 

public class MyObject : SortedList

{

   // some code here

  public new object this[object key]

   {

      get { return base[key.ToString()]; }

      set { base[key] = value;  }

   }

 

Now in my VBScript when I have this code

Set x = MyObject.Item["0"]

It complains that it cannot bind to the Item. So how to I make the VBScript.net translate that MyObject.Item is to be implemented by this[object key]. 

Hope this gives you more information. If needed I can send you a sample code for the same.

Coordinator
May 20, 2010 at 5:45 AM
Please try to use:
x = MyObject("0")
You should be able to access indexer without the Item property. The Set statement is used with COM object. Sorry that I am quite busy these couple of weeks. I will try to find some time this weekend to look into it.
Li

From: [email removed]
Sent: Wednesday, May 19, 2010 6:22 PM
To: [email removed]
Subject: Re: Passing complex object to Script Control [aspclassiccompiler:213103]

From: manthangogari

The issue that I am having is that the VBScript.net does not recognize the SortedList.Item property when I have overriden it in my child class.

What i have done is I have

public class MyObject : SortedList

{

// some code here

public new object this[object key]

{

get { return base[key.ToString()]; }

set { base[key] = value; }

}

Now in my VBScript when I have this code

Set x = MyObject.Item["0"]

It complains that it cannot bind to the Item. So how to I make the VBScript.net translate that MyObject.Item is to be implemented by this[object key].

Hope this gives you more information. If needed I can send you a sample code for the same.

May 20, 2010 at 5:51 AM
Thanks for the prompt response. I will try that and let you know if there are further issues.

On Thu, May 20, 2010 at 2:46 PM, dotneteer <notifications@codeplex.com> wrote:

From: dotneteer

Please try to use:
x = MyObject("0")
You should be able to access indexer without the Item property. The Set statement is used with COM object. Sorry that I am quite busy these couple of weeks. I will try to find some time this weekend to look into it.
Li

From: [email removed]
Sent: Wednesday, May 19, 2010 6:22 PM
To: [email removed]
Subject: Re: Passing complex object to Script Control [aspclassiccompiler:213103]

From: manthangogari

The issue that I am having is that the VBScript.net does not recognize the SortedList.Item property when I have overriden it in my child class.

What i have done is I have

public class MyObject : SortedList

{

// some code here

public new object this[object key]

{

get { return base[key.ToString()]; }

set { base[key] = value; }

}

Now in my VBScript when I have this code

Set x = MyObject.Item["0"]

It complains that it cannot bind to the Item. So how to I make the VBScript.net translate that MyObject.Item is to be implemented by this[object key].

Hope this gives you more information. If needed I can send you a sample code for the same.

Read the full discussion online.

To add a post to this discussion, reply to this email (aspclassiccompiler@discussions.codeplex.com)

To start a new discussion for this project, email aspclassiccompiler@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Sincerely,

Manthan Gogari