Esempio n. 1
0
        public bool PassCommand(string filename, string encoding)
        {
            var clientChanel = new LocalIpcChannel();

            ChannelServices.RegisterChannel(clientChanel, false);
            var          u   = "ipc://" + GetChannelName() + "/" + GetObjectName();
            IMyPadServer obj = (IMyPadServer)Activator.GetObject(typeof(IMyPadServer), u);

            try
            {
                obj.OpenPage(filename, encoding);
                return(true);
            }
            catch (RemotingException ex)
            {
                // Connection refused
                // error code -2146233087 = 0x80131501 (Failed to connect to server)
                Trace.WriteLine(ex.ToString());
                return(false);
            }
            finally
            {
                ChannelServices.UnregisterChannel(clientChanel);
            }
        }
        public bool PassCommand(string filename, string encoding)
        {
            IpcChannel clientChanel = new IpcChannel("myClient");

            ChannelServices.RegisterChannel(clientChanel, false);
            IMyPadServer obj = (IMyPadServer)Activator.GetObject(
                typeof(IMyPadServer),
                "ipc://" + GetChannelName() + "/" + GetObjectName());

            try
            {
                obj.OpenPage(filename, encoding);
                return(true);
            }
            catch (RemotingException)
            {
                // Connection refused
                return(false);
            }
            finally
            {
                ChannelServices.UnregisterChannel(clientChanel);
            }
        }