Type casting

Class library usage, coding and language questions.
dbi1463
Posts: 1
Joined: Wed Nov 28, 2007 10:50 am

Type casting

Post by dbi1463 » Wed Nov 28, 2007 10:58 am

I'm a TA of a Windows Programming course in a Taiwan univeristy. We use Ranorex (free edition) for GUI automation and testing. I has a class in a C# program: KeynoterView inherited System.Windows.Forms.Form. I used RanorexNet to start the application, and actually it works fine.
However, there still exists a problem that I want to cast Ranorex.Form to KeynoterView because I want to call some methods in KeynoterView for testing. How do I do?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Nov 28, 2007 11:41 am

I'm sorry, but C# casting doesn't work that way. Since Ranorex.Form does not inherit from KeynoterView, you cannot cast an instance of Ranorex.Form to your custom form.

Ranorex.Control (which is the base class for Ranorex.Form) is just a wrapper that makes properties and methods of a Control from a separate process available to the process running Ranorex. I.e., it's not an instance of the actual class running in your KeynoterView application.

Currently, Ranorex supports accessing the most common properties of Controls from another process. Ranorex 1.4 (Professional version) will include the possibility to access all public properties and methods of controls, even those of custom controls.

Regards,
Alex
Ranorex Support Team