/// <summary> /// Register the ipc client proxy /// </summary> internal void RegisterProxy() { try { string uri = "ipc://NetOffice.SampleChannel/NetOffice.WebTranslationService.DataService"; //Create an IPC client channel. _channel = new IpcClientChannel(); //Register the channel with ChannelServices. ChannelServices.RegisterChannel(_channel, true); //Register the client type. WellKnownClientTypeEntry[] entries = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); if (null == GetEntry(entries, uri)) { RemotingConfiguration.RegisterWellKnownClientType( typeof(WebTranslationService), uri); } DataService = new WebTranslationService(); // try to do some action to see the server is alive string[] dumy = DataService.AvailableTranslations; } catch (RemotingException exception) { // rethrow the exception with a friendly message throw new RemotingException("Unable to connect the local translation service.", exception); } catch (Exception) { throw; } }
/// <summary> /// Register the Service Property as IPC Server /// </summary> private void RegisterServer() { Repeater = new DataEventRepeator(); IpcServerChannel channel = new IpcServerChannel("NetOffice.SampleChannel"); ChannelServices.RegisterChannel(channel, true); RemotingConfiguration.RegisterWellKnownServiceType( typeof(WebTranslationService), "NetOffice.WebTranslationService.DataService", WellKnownObjectMode.Singleton); Service = new WebTranslationService(); Repeater.Translation += new TranslationEventHandler(ServiceOnTranslation); Service.AddEventRepeater(Repeater); }
/// <summary> /// Register the ipc client proxy /// </summary> internal void RegisterProxy() { //Create an IPC client channel. IpcClientChannel channel = new IpcClientChannel(); //Register the channel with ChannelServices. ChannelServices.RegisterChannel(channel, true); //Register the client type. RemotingConfiguration.RegisterWellKnownClientType( typeof(WebTranslationService), "ipc://NetOffice.SampleChannel/NetOffice.WebTranslationService.DataService"); DataService = new WebTranslationService(); }