public void Connect()
        {
            _ChannelName = null;
            log.Info("Dll to inject: " + _InjectDll);
            try
            {
                log.Info("  Creating IPC server");
                IpcServer = RemoteHooking.IpcCreateServer <PSInterface>(
                    ref _ChannelName, System.Runtime.Remoting.WellKnownObjectMode.Singleton);

                log.Info("  Connect to IPC as client to get interface");
                Iface = RemoteHooking.IpcConnectClient <PSInterface>(_ChannelName);
                ;
                log.Info("  Set interface properties");
                Iface.RunButton = Valve.VR.EVRButtonId.k_EButton_Axis0;
                log.Info("    Interface RunButton: " + Iface.RunButton);
                Iface.ButtonType = PStrafeButtonType.Press;
                log.Info("    Interface ButtonType: " + Iface.ButtonType);
                Iface.Hand = PStrafeHand.Left;
                log.Info("    Interface Hand: " + Iface.Hand);

                log.Info("  Subscribe to interface events:");
                log.Info("    UserIsRunning event");
                this.WhenAnyValue(x => x.UserIsRunning)
                .Do(x => Iface.UserIsRunning = x)
                .Subscribe();
            }
            catch (Exception ex)
            {
                log.Error("  EasyHook Error: " + ex.Message);
                log.Error(ex);
                throw new PocketStrafeOutputDeviceException(ex.Message);
            }
        }
 protected override void OnStop()
 {
     base.OnStop();
     if (ipcServer != null)
     {
         System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(ipcServer);
     }
     ipcServer = null;
 }
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);

            if (ipcServer == null)
            {
                //ipcServer = new System.Runtime.Remoting.Channels.Ipc.IpcServerChannel("MyServicePort");
                System.Collections.IDictionary properties =
                    new System.Collections.Hashtable();
                properties["name"]            = "ipc";
                properties["authorizedGroup"] = "Everyone";
                properties["portName"]        = "MyServicePort";
                ipcServer = new System.Runtime.Remoting.Channels.Ipc.IpcServerChannel(properties, null);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ipcServer, false);
                System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(typeof(ControlClass), "MyServiceControl", System.Runtime.Remoting.WellKnownObjectMode.Singleton);
                Console.WriteLine(ipcServer.GetChannelUri());
            }
        }