Invoke Remotely Failure

Ask general questions here.
Captain Nemo
Posts: 17
Joined: Tue Dec 02, 2008 10:09 am

Invoke Remotely Failure

Post by Captain Nemo » Thu Apr 16, 2009 4:51 pm

I have this simple code:

[STAThread]
public static int Main(string[] args)
{

PluginManager.Instance.LoadDefaultPlugins();

Ranorex.Core.Element el = "/form[@controlname='MainForm']/element[@controlname='ribbon']";
Ranorex.Control ctrl = new Control(el);
ctrl.Click();
string value = (string)ctrl.InvokeRemotely(getSynchronisedRibbonObject);

return 0;
}


static object getSynchronisedRibbonObject(System.Windows.Forms.Control control, object inputData)
{
return "Test";
}

What I get is:

Ranorex.ActionFailedException: Action 'invokeremotely' failed on element '{Unknown:ribbon}'. ---> System.InvalidOperationException: The control does no longer exist.
at Ranorex.Core.Element.InvokeAction
at Ranorex.Control.InvokeRemotely
at Ranorex.Control.InvokeRemotely

The control does indeed exist, as I click it before doing the invokeRemotely call. Can anyone see where I'm going wrong here?

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

Post by Support Team » Fri Apr 17, 2009 10:59 am

Are you starting your testing application from a network share or another location with limited security? The DLLs/EXEs that contain the delegates which should be called remotely need to reside in a location with full trust.

You can either copy your testing executable on a local drive or you can change the .NET security settings using the “Microsoft .NET Framework 2.0 Configuration” program in the found under “Administrative Tools” in your Windows Control Panel where you can edit the “Runtime Security Policy” for your user or machine. For an easy way to just give full trust to your network drive, see the following link how to do that:
http://www.sellsbrothers.com/news/showT ... Topic=1519

Regards,
Alex
Ranorex Support Team

Captain Nemo
Posts: 17
Joined: Tue Dec 02, 2008 10:09 am

Post by Captain Nemo » Tue Apr 21, 2009 1:14 pm

The problem was that I was running the testing app in a different directory to the application under test. After copying my dll's to that location and running from there, no problems at all.

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

Post by Support Team » Tue Apr 21, 2009 6:18 pm

Usually, that should not be needed, unless you did not install Ranorex on that computer and just copied all the Ranorex DLLs to the directory containing your testing app.

Regards,
Alex
Ranorex Support Team

Captain Nemo
Posts: 17
Joined: Tue Dec 02, 2008 10:09 am

Post by Captain Nemo » Wed Apr 22, 2009 9:21 am

Ranorex is installed and licensed properly on the machine, I've always had to use this approach when using InvokeRemotely.

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

Post by Support Team » Wed Apr 22, 2009 9:57 am

As Alex mentioned before it can be an security restriction issue (Network Drive etc). There can also be a problem when your referenced "Delegate DLL`s" are in your home folder (C:\Documents and Settings\User...)

Regards,
Christian
Ranorex

Captain Nemo
Posts: 17
Joined: Tue Dec 02, 2008 10:09 am

Post by Captain Nemo » Wed Apr 22, 2009 10:02 am

You've hit that one on the head, my test suite is located in a folder on my desktop.