Process currentProcess = Process.GetCurrentProcess(); Process [] duplicateProcesses = Process.GetProcessesByName(currentProcess.ProcessName); if (duplicateProcesses.Length == 1) { AssociateFileTypes(); TcpChannel chan = new TcpChannel(8420); ChannelServices.RegisterChannel(chan); RemotingConfiguration.RegisterWellKnownServiceType( System.Type.GetType("InteractiveLogBook.RemoteExecute, InteractiveLogBook"), "RemoteExecute", WellKnownObjectMode.SingleCall); } else { TcpChannel chan = new TcpChannel(); ChannelServices.RegisterChannel(chan); RemoteExecute obj = (RemoteExecute) Activator.GetObject(typeof(RemoteExecute), "tcp://127.0.0.1:8420/RemoteExecute"); if (obj == null) MessageBox.Show("Could not locate running Interactive LogBook", "Error", MessageBoxButtons.OK,MessageBoxIcon.Error); else obj.ProcessArgs(args); return; } public class RemoteExecute : MarshalByRefObject { public RemoteExecute() { } public bool ProcessArgs(String[] Args) { InteractiveLogBook.FormILB.mainForm.ProcessCommandLine(Args); return true; } } |
Tuesday, April 19, 2005
.Net Remoting
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment