Ranorex

Using InvokeMethod and GetPropertyValue

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
Marianne Jacobsen



Joined: 26 Oct 2007
Posts: 15

PostPosted: Wed Jul 09, 2008 1:19 pm    Post subject: Using InvokeMethod and GetPropertyValue
I'm having trouble understanding how InvokeMethod and GetPropertyValue works.

I'm testing on 3rd party controls and enjoy the feature of calling custom methods and properties. Nevertheless I've run into some problems - some methods/properties simply return null. The reason for this is unclear to me and the Ranorex documentation does not provide much help.

I'm calling a property named Items but it returns null. I've set ErrorAsException to true but I get no exception - which may indicate that the property is actually null (even though I don't think it is). But if I try to call it with "get_Items" using InvokeMethod I get an InvalidOperationException with the message "The control does no longer exist." but it does. I can click it, see it and check other properties just fine.

Some information would be appreciated. Thanks for your time.
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Thu Jul 10, 2008 5:35 pm    Post subject:
The problem is that these methods cross process boundaries and therefore the parameters and return values need to be serializable, i.e. transferable between process boundaries. The GetPropertyValue and InvokeMethod methods will return null if the returned value is not serializable. All primitive types (like int, double, string, …) are serializable and all classes marked with the Serializable attribute. For all other return types you need to provide some way to make the wanted data serializable.

With Ranorex 1.4 the only way was to provide a helper method in the control you want the data from. However, that often implies a change request to the control developer which often takes some time and sometimes isn't even possible.

That's why with Ranorex 1.5 we introduced a new way that does not imply a code change to the automated control: the Control.InvokeRemotely method. Using the Control.InvokeRemotely method one can define a delegate in the Ranorex code that is executed in the process of the automated control. This delegate should collect the wanted data and needs to return it in a serializable format (e.g. as a list of strings or integers).

I will write a Ranorex blog entry next week that will provide an example on how to use the Control.InvokeRemotely method - just in case the API documentation is not clear enough Smile

Regards,
Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
Marianne Jacobsen



Joined: 26 Oct 2007
Posts: 15

PostPosted: Mon Jul 14, 2008 10:34 am    Post subject:
Thank you very much for the extensive explanation - it's very appreciated.

I'm pretty sure that the Serializable attribute is why I get null when invoking the custom methods/properties.

I look forward to your blog entry.
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Mon Jul 14, 2008 11:39 am    Post subject:
I just finished the blog post, you can find it here:
http://www.ranorex.com/blog/transfering-data-to-and-from-a-net-control

Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
Marianne Jacobsen



Joined: 26 Oct 2007
Posts: 15

PostPosted: Mon Jul 14, 2008 12:36 pm    Post subject:
I see that it has been posted. Thank you very much.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum