/// <summary> /// Register remoting channel and types /// </summary> private PtAccClient() { IpcClientChannel clientChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(clientChannel, true); RemotingConfiguration.RegisterWellKnownClientType(typeof(PtAccRemoteType), "ipc://remote/PtAcc"); _remoteType = new PtAccRemoteType(); }
public static void Send(Program.AppMessage msg, int lParam, bool bWaitWithTimeout) { if(!KeePassLib.Native.NativeLib.IsUnix()) // Windows { if(bWaitWithTimeout) { IntPtr pResult = new IntPtr(0); NativeMethods.SendMessageTimeout((IntPtr)NativeMethods.HWND_BROADCAST, Program.ApplicationMessage, (IntPtr)msg, (IntPtr)lParam, NativeMethods.SMTO_ABORTIFHUNG, 5000, ref pResult); } else NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST, Program.ApplicationMessage, (IntPtr)msg, (IntPtr)lParam); } else // Unix { if(m_chClient == null) { m_chClient = new IpcClientChannel(); ChannelServices.RegisterChannel(m_chClient, false); } try { IpcBroadcastSingleton ipc = (Activator.GetObject(typeof( IpcBroadcastSingleton), "ipc://" + GetPortName() + "/" + IpcObjectName) as IpcBroadcastSingleton); if(ipc != null) ipc.Call((int)msg, lParam); } catch(Exception) { } // Server might not exist } }
/// <summary> /// Start connection with specified engine interface /// </summary> /// <param name="typeEngineInterface">Type of engine interface</param> /// <param name="urlClient">Asscoiated URL</param> /// <param name="ensureSecurity">Remoting security attribute</param> public void Start(string urlClient, bool ensureSecurity, uint timeOut, Type iProxyType) { Trace.TraceInformation("Configuring client connection"); _ensureSecurity = ensureSecurity; #if MONO _sinkProvider = new BinaryClientFormatterSinkProvider(); #endif IDictionary t = new Hashtable(); t.Add("timeout", timeOut); t.Add("name", urlClient); Console.WriteLine("New IPC channel"); // need to make ChannelNames unique so need to use this // constructor even though we dont care about the sink provider _channel = new IpcClientChannel(urlClient, _sinkProvider); Console.WriteLine("\tRegister"); ChannelServices.RegisterChannel(_channel, _ensureSecurity); Console.WriteLine("\tActivate object proxy to IEngine"); _base = (IBase)Activator.GetObject(iProxyType, urlClient); Console.WriteLine("\tActivated."); }
public static void Main (string [] args) { IpcClientChannel channel = new IpcClientChannel (); ChannelServices.RegisterChannel (channel, false); IFoo foo = (IFoo) Activator.GetObject (typeof (IFoo), "ipc://Foo/Foo"); foo.Foo (); }
/// <summary> /// Gets an instance of a <see cref="Messager"/> to use to talk to the running instance of the client. /// </summary> /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param> /// <param name="p_gmdGameModeInfo">The descriptor of the game mode for which mods are being managed.</param> /// <returns>An instance of a <see cref="Messager"/> to use to talk to the running instance of the client, /// or <c>null</c> if no valid <see cref="Messager"/> could be created.</returns> public static IMessager GetMessager(EnvironmentInfo p_eifEnvironmentInfo, IGameModeDescriptor p_gmdGameModeInfo) { if (m_cchMessagerChannel == null) { System.Collections.IDictionary properties = new System.Collections.Hashtable(); properties["exclusiveAddressUse"] = false; m_cchMessagerChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(m_cchMessagerChannel, true); } else throw new InvalidOperationException("The IPC Channel has already been created as a CLIENT."); string strMessagerUri = String.Format("ipc://{0}-{1}IpcServer/{1}Listener", p_eifEnvironmentInfo.Settings.ModManagerName, p_gmdGameModeInfo.ModeId); IMessager msgMessager = null; try { Trace.TraceInformation(String.Format("Getting listener on: {0}", strMessagerUri)); msgMessager = (IMessager)Activator.GetObject(typeof(IMessager), strMessagerUri); //Just because a messager has been returned, dosn't mean it exists. //All you've really done at this point is create an object wrapper of type "Messager" which has the same methods, properties etc... //You wont know if you've got a real object, until you invoke something, hence the post (Power on self test) method. msgMessager.Post(); } catch (RemotingException e) { Trace.TraceError("Could not get Messager: {0}", strMessagerUri); TraceUtil.TraceException(e); return null; } return new MessagerClient(msgMessager); }
/// <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; } }
public void Bug81653 () { IpcClientChannel c = new IpcClientChannel (); ChannelDataStore cd = new ChannelDataStore (new string[] { "foo" }); string objectUri; c.CreateMessageSink (null, cd, out objectUri); }
public VisualStudioInstance(Process process, DTE dte) { _hostProcess = process; _dte = dte; dte.ExecuteCommandAsync(VisualStudioCommandNames.VsStartServiceCommand).GetAwaiter().GetResult(); _integrationServiceChannel = new IpcClientChannel($"IPC channel client for {_hostProcess.Id}", sinkProvider: null); ChannelServices.RegisterChannel(_integrationServiceChannel, ensureSecurity: true); // Connect to a 'well defined, shouldn't conflict' IPC channel var serviceUri = string.Format($"ipc://{IntegrationService.PortNameFormatString}", _hostProcess.Id); _integrationService = (IntegrationService)(Activator.GetObject(typeof(IntegrationService), $"{serviceUri}/{typeof(IntegrationService).FullName}")); _integrationService.Uri = serviceUri; // There is a lot of VS initialization code that goes on, so we want to wait for that to 'settle' before // we start executing any actual code. _integrationService.Execute(typeof(RemotingHelper), nameof(RemotingHelper.WaitForSystemIdle)); _csharpInteractiveWindow = new Lazy<CSharpInteractiveWindow>(() => new CSharpInteractiveWindow(this)); _editorWindow = new Lazy<EditorWindow>(() => new EditorWindow(this)); _solutionExplorer = new Lazy<SolutionExplorer>(() => new SolutionExplorer(this)); _workspace = new Lazy<Workspace>(() => new Workspace(this)); // Ensure we are in a known 'good' state by cleaning up anything changed by the previous instance Cleanup(); }
public MonitorVdmClient() { // Set up communication with the virtual desktop monitoring server. _channel = new IpcClientChannel(); ChannelServices.RegisterChannel( _channel, false ); _monitorVdm = (IMonitorVdmService)Activator.GetObject( typeof( IMonitorVdmService ), "ipc://VirtualDesktopManagerAPI/MonitorVdmService" ); }
public ChromePersistence() : base("chrome", "Google Inc.") { // Set up communication with the Chrome ABC extension. _channel = new IpcClientChannel(); ChannelServices.RegisterChannel( _channel, false ); _chromeService = (IChromeAbcService)Activator.GetObject( typeof( IChromeAbcService ), "ipc://ChromeAbcConnection/ChromeAbcService" ); }
private static void CreateClientChannel(String arg) { IpcClientChannel channel = new IpcClientChannel(); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownClientType(typeof(Ipc), "ipc://" + ipcPortName + "/" + ipcServername); Ipc ipc = new Ipc(); ipc.OpenFile(arg); }
static void Main(string[] args) { if (args == null) throw new ArgumentNullException("args"); if (args.Length != 1) throw new ArgumentException("Arguments number doesn't match!", "args"); var name = args[0]; if (string.IsNullOrEmpty(name)) throw new Exception("Name cannot be null or empty."); name = name.Trim('"'); var channelPort = string.Format(ProcessAppConst.PortNameTemplate, name, Process.GetCurrentProcess().Id); var currentDomain = AppDomain.CurrentDomain; var root = Path.Combine(Path.Combine(currentDomain.BaseDirectory, ProcessAppConst.WorkingDir), name); //Hack to change the default AppDomain's root if (NDockEnv.IsMono) //for Mono { var pro = typeof(AppDomain).GetProperty("SetupInformationNoCopy", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty); var setupInfo = (AppDomainSetup)pro.GetValue(currentDomain, null); setupInfo.ApplicationBase = root; } else // for .NET { currentDomain.SetData("APPBASE", root); } currentDomain.SetData(typeof(IsolationMode).Name, IsolationMode.Process); try { var serverChannel = new IpcServerChannel("IpcAgent", channelPort, new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }); var clientChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(serverChannel, false); ChannelServices.RegisterChannel(clientChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ManagedAppWorker), ProcessAppConst.WorkerRemoteName, WellKnownObjectMode.Singleton); Console.WriteLine("Ok"); var line = Console.ReadLine(); while (!"quit".Equals(line, StringComparison.OrdinalIgnoreCase)) { line = Console.ReadLine(); } } catch { Console.Write("Failed"); } }
static Sounds() { //クライアントのチャンネルを生成 IpcClientChannel channel = new IpcClientChannel(); //チャンネルを登録 ChannelServices.RegisterChannel(channel, true); //リモートオブジェクトの取得 midObject = Activator.GetObject(typeof(IPCSound), "ipc://HoppoAlphaSound/SoundData") as IPCSound; }
/// <summary> /// コンストラクタ /// </summary> public IpcClient() { // クライアントチャンネルの生成 IpcClientChannel channel = new IpcClientChannel(); // チャンネルを登録 ChannelServices.RegisterChannel(channel, true); // リモートオブジェクトを取得 RemoteObject = Activator.GetObject(typeof(IpcRemoteObj), "ipc://" + IpcRemoteObj.ipcAddr + "/" + IpcRemoteObj.ipcAddrCom) as IpcRemoteObj; }
internal IpcClientTransportSink(string channelURI, IpcClientChannel channel) { string str; this.portCache = new ConnectionCache(); this._tokenImpersonationLevel = TokenImpersonationLevel.Identification; this._timeout = 0x3e8; this._channel = channel; string str2 = IpcChannelHelper.ParseURL(channelURI, out str); int startIndex = str2.IndexOf("://") + 3; this._portName = str2.Substring(startIndex); }
static ProcessBootstrap() { // Create the channel. var clientChannel = new IpcClientChannel(); // Register the channel. System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(clientChannel, false); var serverChannel = new IpcServerChannel("Bootstrap", BootstrapIpcPort); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(serverChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ProcessBootstrapProxy), "Bootstrap.rem", WellKnownObjectMode.Singleton); }
public static void Start() { #if !MULTI_START_DEBUG // ゾンビプロセスがいたら殺す var ps = Process.GetProcessesByName("ACT.TTSYukkuri.TTSServer"); if (ps != null) { foreach (var p in ps) { p.Kill(); p.Dispose(); } } var pi = new ProcessStartInfo(ServerProcessPath) { CreateNoWindow = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, }; ServerProcess = Process.Start(pi); #endif channel = new IpcClientChannel(); ChannelServices.RegisterChannel(channel, true); Message = (TTSMessage)Activator.GetObject(typeof(TTSMessage), "ipc://TTSYukkuriChannel/message"); // 通信の確立を待つ // 200ms x 150 = 30s var ready = false; var retryCount = 0; while (!ready) { try { Thread.Sleep(200); ready = Message.IsReady(); } catch (Exception ex) { retryCount++; if (retryCount >= 150) { Message = null; throw new Exception( "TT制御プロセスへの接続がタイムアウトしました。", ex); } } } }
/// <summary> /// Mains the specified args. /// </summary> /// <param name="args">The args.</param> static void Main(string[] args) { if (args == null) throw new ArgumentNullException("args"); if(args.Length != 3) throw new ArgumentException("Arguments number doesn't match!", "args"); var name = args[0]; if(string.IsNullOrEmpty(name)) throw new Exception("Name cannot be null or empty."); name = name.Trim('"'); var channelPort = args[1]; if (string.IsNullOrEmpty(channelPort)) throw new Exception("Channel port cannot be null or empty."); channelPort = channelPort.Trim('"'); channelPort = string.Format(channelPort, Process.GetCurrentProcess().Id); var root = args[2]; if (string.IsNullOrEmpty(root)) throw new Exception("Root cannot be null or empty."); AppDomain.CurrentDomain.SetData("APPBASE", root); AppDomain.CurrentDomain.SetData(typeof(IsolationMode).Name, IsolationMode.Process); try { var serverChannel = new IpcServerChannel("IpcAgent", channelPort); var clientChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(serverChannel, false); ChannelServices.RegisterChannel(clientChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WorkItemAgent), "WorkItemAgent.rem", WellKnownObjectMode.Singleton); Console.WriteLine("Ok"); var line = Console.ReadLine(); while (!"quit".Equals(line, StringComparison.OrdinalIgnoreCase)) { line = Console.ReadLine(); } } catch { Console.WriteLine("Failed"); } }
public static void InitializeClient(string objectUri, string portName, System.Type type) { if (_clientChannel != null) { Logger.Info("IpcHelper.InitializeClient chiude il canale aperto ..."); ChannelServices.UnregisterChannel(_clientChannel); } Hashtable props = new Hashtable(); props.Add("connectionTimeout", 100000); _clientChannel = new IpcClientChannel(props, null); ChannelServices.RegisterChannel(_clientChannel, true); RemotingConfiguration.RegisterWellKnownClientType(type, string.Format("ipc://{0}/{1}", portName, objectUri)); Logger.Info("CacheClientHelper inizializzato"); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessBootstrap" /> class. /// </summary> /// <param name="config">The config.</param> public ProcessBootstrap(IConfigurationSource config) : base(config) { var clientChannel = ChannelServices.RegisteredChannels.FirstOrDefault(c => c is IpcClientChannel); if(clientChannel == null) { // Create the channel. clientChannel = new IpcClientChannel(); // Register the channel. ChannelServices.RegisterChannel(clientChannel, false); } }
internal IpcClientTransportSink(String channelURI, IpcClientChannel channel) { String objectURI; _channel = channel; // Parse the URI String simpleChannelUri = IpcChannelHelper.ParseURL(channelURI, out objectURI); // extract machine name and port int start = simpleChannelUri.IndexOf("://"); start += 3; _portName = simpleChannelUri.Substring(start);; } // IpcClientTransportSink
private static void UpdateRemoteObject(string uri) { IpcClientChannel clientChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(clientChannel, true); InstanceProxy proxy = Activator.GetObject(typeof(InstanceProxy), string.Format("ipc://{0}{1}/{1}", Environment.MachineName, uri)) as InstanceProxy; if (proxy != null) { proxy.SetCommandLineArgs(InstanceProxy.IsFirstInstance, InstanceProxy.CommandLineArgs); } ChannelServices.UnregisterChannel(clientChannel); }
public IpcChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, CommonSecurityDescriptor securityDescriptor) { this._channelPriority = 20; this._channelName = "ipc"; Hashtable hashtable = new Hashtable(); Hashtable hashtable2 = new Hashtable(); bool flag = false; if (properties != null) { foreach (DictionaryEntry entry in properties) { string key = (string)entry.Key; if (key == null) { goto Label_00CC; } if (!(key == "name")) { if (key == "priority") { goto Label_0098; } if (key == "portName") { goto Label_00B6; } goto Label_00CC; } this._channelName = (string)entry.Value; continue; Label_0098: this._channelPriority = Convert.ToInt32((string)entry.Value, CultureInfo.InvariantCulture); continue; Label_00B6: hashtable2["portName"] = entry.Value; flag = true; continue; Label_00CC: hashtable[entry.Key] = entry.Value; hashtable2[entry.Key] = entry.Value; } } this._clientChannel = new IpcClientChannel(hashtable, clientSinkProvider); if (flag) { this._serverChannel = new IpcServerChannel(hashtable2, serverSinkProvider, securityDescriptor); } }
/// <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(); }
public void RegistersTheChannelDuringConstructionAndUnregistersItOnDispose() { IpcClientChannel channel = new IpcClientChannel(); Uri uri = new Uri("ipc://foo"); using (StubChannel stub = new StubChannel(channel, uri)) { Assert.Contains(ChannelServices.RegisteredChannels, channel); Assert.AreSame(channel, stub.Channel); Assert.AreEqual(uri, stub.ChannelUri); } Assert.DoesNotContain(ChannelServices.RegisteredChannels, channel); }
public static void SignalFirstInstance(string[] args) { // Issue 236 // The actual exception comes from this method, but // if we accurately detected if another instance was // running or not, then this would not be a problem. string objectUri = String.Format(CultureInfo.InvariantCulture, "ipc://hfm-{0}-{1}/{2}", Environment.UserName, AssemblyGuid, ObjectName); IChannel ipcChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(ipcChannel, false); var obj = (IpcObject)Activator.GetObject(typeof(IpcObject), objectUri); obj.SignalNewInstance(args); }
public void SendLaunchInfoToFirstInstance(LaunchInfo launchInfo) { if (IsFirstInstance) { throw new InvalidOperationException(); } IpcClientChannel channel = new IpcClientChannel(ApplicationId, null); ChannelServices.RegisterChannel(channel, true); IFirstInstanceServer server = (IFirstInstanceServer) Activator.GetObject(typeof (IFirstInstanceServer), string.Format("ipc://{0}/{0}", ApplicationId)); server.ProcessLaunchInfo(launchInfo); }
public IpcChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, CommonSecurityDescriptor securityDescriptor) { this._channelPriority = 20; this._channelName = "ipc"; Hashtable hashtable = new Hashtable(); Hashtable hashtable2 = new Hashtable(); bool flag = false; if (properties != null) { foreach (DictionaryEntry entry in properties) { string key = (string) entry.Key; if (key == null) { goto Label_00CC; } if (!(key == "name")) { if (key == "priority") { goto Label_0098; } if (key == "portName") { goto Label_00B6; } goto Label_00CC; } this._channelName = (string) entry.Value; continue; Label_0098: this._channelPriority = Convert.ToInt32((string) entry.Value, CultureInfo.InvariantCulture); continue; Label_00B6: hashtable2["portName"] = entry.Value; flag = true; continue; Label_00CC: hashtable[entry.Key] = entry.Value; hashtable2[entry.Key] = entry.Value; } } this._clientChannel = new IpcClientChannel(hashtable, clientSinkProvider); if (flag) { this._serverChannel = new IpcServerChannel(hashtable2, serverSinkProvider, securityDescriptor); } }
//[ClassCleanup] public static void ClassCleanup() { _testServer = null; if (_clientChannel != null) { ChannelServices.UnregisterChannel(_clientChannel); _clientChannel = null; } if (_serverDomain != null) { AppDomain.Unload(_serverDomain); _serverDomain = null; } }
//[ClassInitialize] public static void ClassInitialize(TestContext context) { _serverDomain = AppDomain.CreateDomain("ServerDomain #2", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation); _serverDomain.DoCallBack(() => { var serverChannel = new IpcServerChannel("ipc server #2", "localhost:9091", new ProtobufServerFormatterSinkProvider { FallbackToBinaryFormatter = true }); ChannelServices.RegisterChannel(serverChannel, false); RemotingServices.Marshal(new TestServer(), "TestServer", typeof(ITestServer)); }); _clientChannel = new IpcClientChannel("ipc client #2", new BinaryClientFormatterSinkProvider()); ChannelServices.RegisterChannel(_clientChannel, false); _testServer = (ITestServer)Activator.GetObject(typeof(TestServer), "ipc://localhost:9091/TestServer"); }
static void Main(String[] args) { // 多重起動 var mutex = new Mutex(false, "SassTray"); if (!mutex.WaitOne(0)) { var serverChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(serverChannel, true); var server = (Server)Activator.GetObject(typeof(Server), "ipc://SassTray/Server"); server.StartWatch(args); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ApplicationCore(mutex, args)); }
public MonitorPanel() { InitializeComponent(); ListViewHelper.EnableDoubleBuffer(ProcessListView); SelectedGroupBox.Visible = false; try { XChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(XChannel, false); } catch { LastErrorLabel.Text = "Unabled to open IPC channel"; } }
public IpcChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, CommonSecurityDescriptor securityDescriptor) { Hashtable clientData = new Hashtable(); Hashtable serverData = new Hashtable(); bool portFound = false; // divide properties up for respective channels if (properties != null) { foreach (DictionaryEntry entry in properties) { switch ((String)entry.Key) { // general channel properties case "name": _channelName = (String)entry.Value; break; case "priority": _channelPriority = Convert.ToInt32((String)entry.Value, CultureInfo.InvariantCulture); break; case "portName": { serverData["portName"] = entry.Value; portFound = true; break; } default: clientData[entry.Key] = entry.Value; serverData[entry.Key] = entry.Value; break; } } } _clientChannel = new IpcClientChannel(clientData, clientSinkProvider); if (portFound) { _serverChannel = new IpcServerChannel(serverData, serverSinkProvider, securityDescriptor); } } // IpcChannel
public IpcChannel() { this._channelPriority = 20; this._channelName = "ipc"; this._clientChannel = new IpcClientChannel(); }
private String _channelName = "ipc"; // channel name public IpcChannel() { _clientChannel = new IpcClientChannel(); // server channel will not be activated. } // IpcChannel