I have some code in which I use System.Runtime.InteropServices.Marshal.GetActiveOb ject to get a reference to an instance of a form that is already running and would like to make a call to a method of this instance. What I am trying to accomplish is to have only one instance of my application running at one time, but to have each following instance send parameters to the one already running. The application has a main entry point outside of the form and in this EntryPoint.cs class I have code to check if there is already an instance of the application in the ROT (Running Object Table) and if there is already an instancec running I would like to pass parameters to the form and then call the form's Show() method so that it can refresh the GUI with the new parameters. I have everything running except for the exception that I get when trying to call a method on the already running instance of the form. The exception message is: {"This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server." }
Does someone have any idea of what is the correct way of calling a method on such a class. I have already searched for topics on .NET remoting, but they all point to a client and server and a TCP or HTTP Chanell, wich kind of confuses me since I do not think I need a Channel using those protocols.
Here is the code I have at the moment:
Code:
try
{
MessageBox.Show("trying to get form from ROT table");
Object objMainForm = System.Runtime.InteropServices.Marshal.GetActiveObject("XimisRadTransSolution.MainForm");
MessageBox.Show("got object obj main form");
theForm = (MainForm)objMainForm;
MessageBox.Show("casting the form");
theForm.setParams(argHashTable);
MessageBox.Show("already passed parameters");
theForm.Show();
}
catch (Exception e)
{}