Receiving SerializationException using InvokeRemotely

Class library usage, coding and language questions.
DDP
Posts: 3
Joined: Tue Mar 15, 2011 2:54 pm

Receiving SerializationException using InvokeRemotely

Post by DDP » Tue Mar 15, 2011 3:05 pm

I'm attempting to interact with a third party control (FarPoint Spread) by using the InvokeRemotely method. I've used the following blog post as a guideline for writing this code:

http://www.ranorex.com/blog/transfering ... et-control

The FarPoint Spread is an Excel-like spreadsheet control that has several rows and columns that all contain some data. I am attempting to use the InvokeRemotely method to retrieve a 2-dimensional array of values representing the cells in the spread. The code I have come up with is as follows:

Code: Select all

Ranorex.Control spread = new Ranorex.Control(spreadControl.Element);
string[][] cellValues = (string[][])spread.InvokeRemotely(
         delegate(System.Windows.Forms.Control control, object input)
         {
                StandardSpreadsheetControl ssc = (StandardSpreadsheetControl)control;
                FarPoint.Win.Spread.SheetView sv = ssc.ActiveSheet;
                                                    
                string[,] values = new string[sv.Rows.Count, sv.Columns.Count];

                for (int row = 0; row < sv.Rows.Count; row++)
                {
                         for (int col = 0; col < sv.Columns.Count; col++)
                         {
                                  values[row, col] = 
                                        sv.Cells[row, col].Value.ToString();
                         }
                }
                
                return values;                                                     
        });
However, this code will not execute. Anytime I try to execute this code, I receive the following exception:

Ranorex.ActionFailedException: Action 'invokeremotely' failed on element '{Unknown:fpSpread}'. ---> System.Runtime.Serialization.SerializationException: Failed to get data from remote process.
at Ranorex.Plugin.WinFormsFlavorElement.InvokeRemotely(RemotelyInvokedDelegate deleg, Object inputData, Duration timeout)
at Ranorex.Plugin.WinFormsFlavorElement.InvokeAction(Element element, String name, Object[] args)
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)

Is the code that I have posted above incorrect, or is it just not possible to use the InvokeRemotely method with this third party control?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Receiving SerializationException using InvokeRemotely

Post by Support Team » Tue Mar 15, 2011 5:46 pm

Hi,

Have you tried to return a single value yet?
Maybe .Net Framework has problems to return multiple dimensional arrays, because your code looks correct.

Regards,
Peter
Ranorex Team
.
Image

DDP
Posts: 3
Joined: Tue Mar 15, 2011 2:54 pm

Re: Receiving SerializationException using InvokeRemotely

Post by DDP » Tue Mar 15, 2011 6:04 pm

Yes, I have tried returning a different data type from the delegate. Even the following code results in the same exact error:

Code: Select all

    Ranorex.Control spread = new Ranorex.Control(spreadControl.Element);
    bool returnVal = (bool)spread.InvokeRemotely(
             delegate(System.Windows.Forms.Control control, object input)
             {
                    return true;                                                     
            });

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Receiving SerializationException using InvokeRemotely

Post by Support Team » Wed Mar 16, 2011 3:33 pm

Hi,

Could you please try to use a static method in a separate class instead of the anonymous method? The problem seems to be that the delegate to be invoked cannot be loaded in the remote control.
And can you post your whole code? I already installed the FarPoint Spread Controls in order to reproduce your issue.

Regards,
Peter
Ranorex Team
.
Image

DDP
Posts: 3
Joined: Tue Mar 15, 2011 2:54 pm

Re: Receiving SerializationException using InvokeRemotely

Post by DDP » Wed Mar 16, 2011 8:51 pm

I've modified the code to use a static method instead of the anonymous delegate:

Code: Select all

public static string[,] GetCellValues(System.Windows.Forms.Control control, object input)
{
   StandardSpreadsheetControl ssc = (StandardSpreadsheetControl)control;
   FarPoint.Win.Spread.SheetView sv = ssc.ActiveSheet;

   string[,] values = new string[sv.Rows.Count, sv.Columns.Count];

   for (int row = 0; row < sv.Rows.Count; row++)
   {
      for (int col = 0; col < sv.Columns.Count; col++)
      {
           values[row, col] =
           sv.Cells[row, col].Value.ToString();
      }
   }

       return values;
}

public static string[][] getAllSpreadCellValues(Ranorex.Unknown spreadControl)
{
    Ranorex.Control spread = new Ranorex.Control(spreadControl.Element);
    string[][] cellValues = (string[][])spread.InvokeRemotely(GetCellValues);

     return cellValues;
}
The only other relevant code is the actual call to getAllSpreadCellValues, which is fairly straightforward:

Code: Select all

string[][] values = Spread.getAllSpreadCellValues(spreadControl);
Using this static method I'm still getting the exact same error.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Receiving SerializationException using InvokeRemotely

Post by Support Team » Wed Mar 16, 2011 11:20 pm

DDP wrote:I've modified the code to use a static method instead of the anonymous delegate
Did you also put the methods into a separate class that is marked Serializable?

Do you get any technology limitation pop-ups or warnings when automating the control?
Please, make sure that none of the reasons described in the following User Guide section apply to the AUT nor to the automating process:
http://www.ranorex.com/support/user-gui ... html#c3250

Regards,
Alex
Ranorex Team
.
Image