InvokeRemotely & DevExpress Grid

Ask general questions here.
chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Tue Sep 08, 2009 4:43 pm

Has anyone used InvokeRemotely to further interrogate a DevExpress xtraGrid?

I want to get the image in a cell in such a grid, but I can't get anything returned at the moment. It either returns null, or complains that the control is no longer in existance (when it is).

Any thoughts anyone?

Cheers

Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: InvokeRemotely & DevExpress Grid

Post by Ciege » Tue Sep 08, 2009 6:34 pm

Sorry have not tried that one.

what are you trying to accomplish with the image? Do you just want to put that image in the log? If so, can you get the cell object then use the report.screenshot(cell_object) functionality within Ranorex to put the cell image in the log?

Sorry if that is not what you are looking for.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Wed Sep 09, 2009 8:12 am

I'm trying to get an image out of the cell then fuzzy compare that image against one from our resource file, to check it is the right one...

Or just the image index would do... but I can't seem to "InvokeRemotely" anything out of the grid, I just get errors.
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: InvokeRemotely & DevExpress Grid

Post by Support Team » Wed Sep 09, 2009 9:28 am

InvokeRemotely should work with DevExpress, several Ranorex customers (and our own samples) use this method with DevExpress controls.

Please, make sure that neither Ranorex nor your DevExpress assemblies are installed on a network drive or in an encrypted folder. Ranorex needs access to the DevExpress assemblies and if they are in such a location, Ranorex possibly can't load the assemblies.

Have you tried returning anything simple like a constant integer in your InvokeRemotelyDelegate method? That way you can check whether the InvokeRemotely works at all.

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Wed Sep 09, 2009 10:07 am

Can I confirm that I'm calling it correctly then... (this is using the devexpress xtragrid tutorials app on the "Custom Draw" page.)

When the test is run, the assertion fires because outputData1 is null. I'm sure I'm doing something stupid here, but I really can see what it is...

Code: Select all


 [Test]
        public void GetValueFromGrid()
        {
            Control gridcontrol = "/form[@controlname='frmMain']/container[@controlname='pcMain']/container[@controlname='gcContainer']/container[@controlname='GridCustomDraw']/element[@controlname='gridControl1']";

            SerializableGridData[] outputData1 = (SerializableGridData[])gridcontrol.InvokeRemotely(GetDataDelegate);

            Assert.NotNull(outputData1);
        }

        [Serializable]
        private class SerializableGridData
        {
            public string  control;

        }

        private static object GetDataDelegate(System.Windows.Forms.Control control, object unused)
        {
            var remoteGrid = (DevExpress.XtraGrid.GridControl)control;

            List<SerializableGridData> remoteOutputData = new List<SerializableGridData>();

            SerializableGridData data = new SerializableGridData();

            data.control = "some text";

            remoteOutputData.Add(data);

            return remoteOutputData.ToArray();
        }


}

Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: InvokeRemotely & DevExpress Grid

Post by Support Team » Wed Sep 09, 2009 11:04 am

Your code looks OK to me, could you post the code for the GetDataDelegate method, too?

If null is returned, it could be that the return value of your method is either null or not serializable! You should try with a very simple delegate method like the one below:
public object RemotelyInvokedDelegate(WinForms.Control control, object inputData)
{
    return 12345;
}
Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Wed Sep 09, 2009 11:55 am

GetDataDelegate is already in that code, just scroll down a bit ;-)

And I'm returning a string in the serializable object, so that should be fine.
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: InvokeRemotely & DevExpress Grid

Post by Support Team » Wed Sep 09, 2009 12:56 pm

chrisgeorge wrote:GetDataDelegate is already in that code, just scroll down a bit ;-)
Ooops, sorry, my fault :-)

Please, try to return a simple constant value in the GetDataDelegate method (no array). If that works, try to make the SerializableGridData class public.

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Wed Sep 09, 2009 1:09 pm

I tried this...

Code: Select all

 [Test]
        public void GetValueFromGrid()
        {
            Control gridcontrol = "/form[@controlname='frmMain']/container[@controlname='pcMain']/container[@controlname='gcContainer']/container[@controlname='GridCustomDraw']/element[@controlname='gridControl1']";

            object outputData1 = gridcontrol.InvokeRemotely(GetDataDelegate);

            Assert.NotNull(outputData1);
        }

        private static object GetDataDelegate(System.Windows.Forms.Control control, object unused)
        {           
            return 12345;
        }
and it still triggers the NotNull assertion... It must be something to do with the control under test...
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: InvokeRemotely & DevExpress Grid

Post by Support Team » Wed Sep 09, 2009 1:25 pm

It could be a security issue then, please refer to the following forum thread which discusses possible causes for that InvokeRemotely problem:
http://www.ranorex.com/forum/post2570.html#p2570

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Thu Sep 10, 2009 11:05 am

Hmm... okay, I got it to work by copying the DevX grid tutorial app into by debug folder.

I then tried the same code against our devx grid in our plugin to SQL Server management studio, and it failed to work.

I tried copying our plugin dlls into the debug folder, and copying the compiled test dlls into our product folder. Both attempts failed.

I'm quickly running out of ideas! :-)
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Thu Sep 10, 2009 11:25 am

Right, on further investigation it seems to not be confined to Devexpress controls.

In SQL Server management studio, on the "Object Explorer Details" page, there is an icon top left next to the name of the object. If I invoke remotely to that, it still returns null.

However, and this has been working for a while, I'm still able to invoke remotely onto the object explorer tree control to get tree item images back, and this works fine.

Code for the failing example:

Code: Select all

[Test]
        public void GetValueFromPicture()
        {           
            Control picturecontrol = @"/form[@title~'^Microsoft\ SQL\ Server\ Mana']/container[@caption='']/element/element[@class='DockingView' and @instance='1']/*/container[@caption='']/*/container[@controlname='rightPaneControl']/*/*/picture[@controlname='iconPlaceholder']";
         
            object outputData1 = gridcontrol.InvokeRemotely(GetDataDelegate);

            picturecontrol .MoveTo(new Point(10, 10));

            Assert.NotNull(outputData1);
        }

private static object GetDataDelegate(System.Windows.Forms.Control control, object unused)
        {           
            return 12345;
        }
(The moveTo is there to make sure the correct control is being found...)
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: InvokeRemotely & DevExpress Grid

Post by Support Team » Thu Sep 10, 2009 11:38 am

That definitely looks like an assembly loading problem, it seems like Ranorex cannot find or is not allowed to load the assemblies containing the code for custom controls - that's why InvokeRemotely works on standard .NET Controls, but not on custom ones.

There are two reasons that come to my mind:
  • There's a bug in Ranorex 2.1.4 when using several AppDomains. If you use more than one AppDomain (e.g. NUnit can be configured to do that), custom Controls might not work, because the containing assemblies are not found.
  • There's a security restriction that does not allow to load assemblies from anywhere except the current directory. This could be the case if you run Ranorex OR the automated application from a network share, from a compressed or encrypted directory, or sometimes even if you run it out of the "Documents and Settings" (WinXP)/"Users" (Vista) directory.
So, please make sure not to use more than one AppDomain and try to move your Ranorex executable and/or the automated program to another folder on your harddisk (e.g. to C:\temp)!

Regards,
Alex
Ranorex Support Team

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: InvokeRemotely & DevExpress Grid

Post by chrisgeorge » Thu Sep 10, 2009 12:07 pm

I've moving everything into the management studio directory and it still doesn't work, even with a simple picture control (which I believe is not custom).

All I actually want to do it get an image out of a devexpress grid cell...
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

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

Re: InvokeRemotely & DevExpress Grid

Post by Support Team » Thu Sep 10, 2009 12:33 pm

DevExpress is a custom control; custom control means every control not being one of the standard .NET controls that are delivered with the .NET framework. I.e. everything that is not in the System.Windows.Forms namespace.

What's about the other reason I mentioned, do you use NUnit or more AppDomains?
What's your operating system (WindowsXP, Vista)? Are you working on a 64 bit environment?

As a workaround you can get a screenshot of the cell by calling the Imaging.CaptureImage method passing the cell element.

Regards,
Alex
Ranorex Support Team