// Token: 0x06000471 RID: 1137 RVA: 0x0001CBC8 File Offset: 0x0001ADC8 private void CreateClient() { try { var productName = Application.ProductName; var ipcChannel = new IpcChannel(); ChannelServices.RegisterChannel(ipcChannel, true); var text = string.Concat(new string[] { ipcChannel.ChannelName, "://", productName, "/", productName, "RemoteObject.rem" }); var entry = new WellKnownClientTypeEntry(typeof(SingletonAppRemoteObject), text); RemotingConfiguration.RegisterWellKnownClientType(entry); ipcChannel.CreateMessageSink(text, null, out var text2); var singletonAppRemoteObject = new SingletonAppRemoteObject(); singletonAppRemoteObject.Startup(_version, _args); } catch { Console.WriteLine("CreateClient Error"); } }
static void Main(string[] args) { // 创建一个IPC信道。 IpcChannel channel = new IpcChannel(); // 注册这个信道。 ChannelServices.RegisterChannel(channel, false); // 注册一个远程对象的客户端代理. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(RemotingObject), "ipc://TestChannel/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); RemotingObject service = new RemotingObject(); Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("called {0} times.", service.GetCount()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("called {0} times.", service.GetCount()); Console.ReadLine(); }
public static object CreateProxyForType(Type type) { // Called by the runtime when creating an instance of a type // that has been registered as remotely activated. // First of all check for remote activation. If the object is not remote, then // it may be contextbound. ActivatedClientTypeEntry activatedEntry = RemotingConfiguration.IsRemotelyActivatedClientType(type); if (activatedEntry != null) { return(RemotingServices.CreateClientProxy(activatedEntry, null)); } WellKnownClientTypeEntry wellknownEntry = RemotingConfiguration.IsWellKnownClientType(type); if (wellknownEntry != null) { return(RemotingServices.CreateClientProxy(wellknownEntry)); } if (type.IsContextful) { return(RemotingServices.CreateClientProxyForContextBound(type, null)); } #if !NET_2_1 if (type.IsCOMObject) { return(RemotingServices.CreateClientProxyForComInterop(type)); } #endif return(null); }
public static void Main() { ChannelServices.RegisterChannel(new TcpChannel()); // Register the 'MyServerImpl' object as well known type // at client end. RemotingConfiguration.RegisterWellKnownClientType( typeof(MyServerImpl), "tcp://localhost:8085/SayHello"); // <Snippet1> MyServerImpl myObject = new MyServerImpl(); // Get the assembly for the 'MyServerImpl' object. Assembly myAssembly = Assembly.GetAssembly(typeof(MyServerImpl)); AssemblyName myName = myAssembly.GetName(); // Check whether the specified object type is registered as // well-known client type. WellKnownClientTypeEntry myWellKnownClientType = RemotingConfiguration.IsWellKnownClientType( (typeof(MyServerImpl)).FullName, myName.Name); Console.WriteLine("The Object type :" + myWellKnownClientType.ObjectType); Console.WriteLine("The Object Uri :" + myWellKnownClientType.ObjectUrl); // </Snippet1> Console.WriteLine(myObject.MyMethod("Remote method is called.")); }
public static void LaunchInExistingInstance(string[] args) { IpcChannel channel = new IpcChannel(); ChannelServices.RegisterChannel(channel, false); string url = String.Format("ipc://{0}/{1}", ChannelName, SingleInstanceServiceName); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(SingleInstanceHelper), url); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink. string objectUri; IMessageSink messageSink = channel.CreateMessageSink(url, null, out objectUri); /* Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } */ SingleInstanceHelper helper = new SingleInstanceHelper(); helper.Run(args); }
public static void Main() { // Create a 'HttpChannel' object and register with channel services. ChannelServices.RegisterChannel(new HttpChannel()); Console.WriteLine(" Start calling from Client One......."); WellKnownClientTypeEntry myWellKnownClientTypeEntry = new WellKnownClientTypeEntry(typeof(HelloServer), "http://localhost:8086/SayHello"); myWellKnownClientTypeEntry.ApplicationUrl = "http://localhost:8086/SayHello"; RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry); // Get the proxy object for the remote object. HelloServer myHelloServerObject = new HelloServer(); // Retrieve an array of object types registered on the // client end as well-known types. WellKnownClientTypeEntry [] myWellKnownClientTypeEntryCollection = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); Console.WriteLine("The Application Url to activate the Remote Object :" + myWellKnownClientTypeEntryCollection[0].ApplicationUrl); Console.WriteLine("The 'WellKnownClientTypeEntry' object :" + myWellKnownClientTypeEntryCollection[0].ToString()); // Make remote method calls. for (int i = 0; i < 5; i++) { Console.WriteLine(myHelloServerObject.HelloMethod(" Client One")); } }
static void Main(string[] args) { RemotingConfiguration.Configure(CONFIG_FILE, false); var services = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); if (services.Length == 0) { Console.WriteLine("You must specify app.config file with wellknown tag inside a service tag."); Console.ReadLine(); return; } var config = ConfigurationSettings.AppSettings; var type = config["type"]; var assembly = config["assembly"]; var brokers = new List <IBrokerClient>(); for (int i = 2; i < config.Count; i++) { WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry(type, assembly, config[i]); brokers.Add((IBrokerClient)Activator.GetObject(entry.ObjectType, entry.ObjectUrl)); } var central = new CentralManager(brokers); ObjRef objrefWellKnown = RemotingServices.Marshal(central, services[0].ObjectUri); Console.WriteLine("Início do Server CentralManager.\n Espera de pedidos"); Console.ReadLine(); }
static void Main(string[] args) { var channel = new IpcChannel(); ChannelServices.RegisterChannel(channel, false); var remoteType = new WellKnownClientTypeEntry( typeof(RemoteObject), "ipc://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink string objectUri; var messageSink = channel.CreateMessageSink( "ipc://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Create an instance of the remote object. var service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); Console.ReadKey(); }
/// <summary> /// Erstellt ein Objekt des angegebenen Typs mittels <b>Activator.GetObject()</b>. /// Der Typ des Objekts muss in der Remoting-Konfiguration als /// WellknownType registriert sein. /// </summary> /// <remarks> /// Die Methode übergibt auch den aktuellen <see cref="IPrincipal"/> /// an den Proxy. /// </remarks> /// <param name="type">Zu erstellender Typ</param> /// <returns>Instanz des Typs <paramref name="type"/></returns> /// <exception cref="RemotingException">Typ ist nicht in der /// Remoting-Konfiguration registriert</exception> public static object GetObject(Type type) { if (!s_initialized) { lock (s_initLock) { if (!s_initialized) { Initialize(); s_initialized = true; } } } WellKnownClientTypeEntry entry = (s_wellKnownTypes.ContainsKey(type) ? s_wellKnownTypes[type] : null); if (entry == null) { RemotingException ex = new RemotingException("Cannot instantiate remote object of type " + (type)); throw ex; } object obj = Activator.GetObject(entry.ObjectType, entry.ObjectUrl); return(obj); }
public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg) { if (RemotingConfigHandler.Info == null) { return(true); } RuntimeType runtimeType = ctorMsg.ActivationType as RuntimeType; if (runtimeType == null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } WellKnownClientTypeEntry wellKnownClientTypeEntry = RemotingConfigHandler.IsWellKnownClientType(runtimeType); string text = (wellKnownClientTypeEntry == null) ? null : wellKnownClientTypeEntry.ObjectUrl; if (text != null) { ctorMsg.Properties["Connect"] = text; return(false); } ActivatedClientTypeEntry activatedClientTypeEntry = RemotingConfigHandler.IsRemotelyActivatedClientType(runtimeType); string text2 = null; if (activatedClientTypeEntry == null) { object[] callSiteActivationAttributes = ctorMsg.CallSiteActivationAttributes; if (callSiteActivationAttributes != null) { for (int i = 0; i < callSiteActivationAttributes.Length; i++) { UrlAttribute urlAttribute = callSiteActivationAttributes[i] as UrlAttribute; if (urlAttribute != null) { text2 = urlAttribute.UrlValue; } } } if (text2 == null) { return(true); } } else { text2 = activatedClientTypeEntry.ApplicationUrl; } string value; if (!text2.EndsWith("/", StringComparison.Ordinal)) { value = text2 + "/RemoteActivationService.rem"; } else { value = text2 + "RemoteActivationService.rem"; } ctorMsg.Properties["Remote"] = value; return(false); }
public static object New(Type type) { if (wellKnownTypes == null) InitTypeCache(); WellKnownClientTypeEntry entry = (WellKnownClientTypeEntry)wellKnownTypes[type]; if (entry == null) throw new RemotingException("Type not found!"); return Activator.GetObject(type, entry.ObjectUrl); }
public RemoteObject GetService() { var remoteType = new WellKnownClientTypeEntry( typeof(RemoteObject), _serverUrl + RemoteObject.ObjURL); RemotingConfiguration.RegisterWellKnownClientType(remoteType); return(new RemoteObject()); }
public static void Main(string[] args) { // Create the channel. HttpClientChannel clientChannel = new HttpClientChannel(); // Register the channel. ChannelServices.RegisterChannel(clientChannel); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(RemoteObject), "http://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = clientChannel.CreateMessageSink( "http://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine( "The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Display the channel's properties using Keys and Item. foreach (string key in clientChannel.Keys) { Console.WriteLine( "clientChannel[{0}] = <{1}>", key, clientChannel[key]); } // Parse the channel's URI. string objectUrl = "http://localhost:9090/RemoteObject.rem"; string channelUri = clientChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); }
public static void Main() { ChannelServices.RegisterChannel(new TcpChannel()); WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(SampleService), "tcp://localhost:9000/SampleServiceUri"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); SampleService service = new SampleService(); Console.WriteLine("Connected to SampleService"); bool returnValue = service.UpdateServer(3, 3.14, "Pi"); }
public static void Main(string[] args) { //<snippet31> // Create the channel. TcpClientChannel clientChannel = new TcpClientChannel("Client", null); //</snippet31> // Register the channel. ChannelServices.RegisterChannel(clientChannel); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry( typeof(RemoteObject), "tcp://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); //<snippet32> // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = clientChannel.CreateMessageSink( "tcp://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } //</snippet32> //<snippet33> // Parse the channel's URI. string objectUrl = "tcp://localhost:9090/RemoteObject.rem"; string channelUri = clientChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); //</snippet33> // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); }
static void Register(HttpClientChannel channel) { // Register the channel. ChannelServices.RegisterChannel(channel); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry( typeof(RemoteObject), "http://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); }
TcpClientChannel GetClientChannel(string name, string uri) { TcpClientChannel clientChannel = new TcpClientChannel(name + "Client", null); ChannelServices.RegisterChannel(clientChannel); WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry( typeof(RemoteObject), uri + "/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); return(clientChannel); }
public static void TransmitMessage(string s) { var channel = new IpcChannel(); ChannelServices.RegisterChannel(channel, false); var remoteType = new WellKnownClientTypeEntry(typeof(MessagePasser), "ipc://localhost:9090/MessagePasser.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); var passer = new MessagePasser(); passer.SendMessage(s); }
public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg) { if (RemotingConfigHandler.Info == null) { return(true); } RuntimeType svrType = ctorMsg.ActivationType as RuntimeType; if (svrType == (RuntimeType)null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } WellKnownClientTypeEntry knownClientTypeEntry = RemotingConfigHandler.IsWellKnownClientType(svrType); string str1 = knownClientTypeEntry == null ? (string)null : knownClientTypeEntry.ObjectUrl; if (str1 != null) { ctorMsg.Properties[(object)"Connect"] = (object)str1; return(false); } ActivatedClientTypeEntry activatedClientTypeEntry = RemotingConfigHandler.IsRemotelyActivatedClientType(svrType); string str2 = (string)null; if (activatedClientTypeEntry == null) { object[] activationAttributes = ctorMsg.CallSiteActivationAttributes; if (activationAttributes != null) { for (int index = 0; index < activationAttributes.Length; ++index) { UrlAttribute urlAttribute = activationAttributes[index] as UrlAttribute; if (urlAttribute != null) { str2 = urlAttribute.UrlValue; } } } if (str2 == null) { return(true); } } else { str2 = activatedClientTypeEntry.ApplicationUrl; } string str3 = str2.EndsWith("/", StringComparison.Ordinal) ? str2 + "RemoteActivationService.rem" : str2 + "/RemoteActivationService.rem"; ctorMsg.Properties[(object)"Remote"] = (object)str3; return(false); }
public bool Connect() { try { WellKnownClientTypeEntry CoRemote = new WellKnownClientTypeEntry(typeof(RpcConnector), "tcp://" + _Ip + ":" + _Port + "/" + typeof(RpcConnector).Name + _Key); if (_Channel == null) { _Channel = new TcpChannel(); ChannelServices.RegisterChannel(_Channel, false); RemotingConfiguration.RegisterWellKnownClientType(CoRemote); } Log.Info("Connect", "Registering connector : " + CoRemote.ObjectUrl); Connector = (RpcConnector)Activator.GetObject(CoRemote.ObjectType, CoRemote.ObjectUrl); _Id = Connector.Connect(_Name); Log.Success("RpcClient", "Connected to : " + _Ip + ":" + _Port); Load(); } catch (Exception e) { Log.Error("RcpClient", "Can not connect to : " + _Ip + ":" + _Port); Log.Error("RpcClient", "Erreur = " + e.ToString()); try { ChannelServices.UnregisterChannel(_Channel); } catch (Exception) { } _Channel = null; return(false); } try { _Ping = new Timer(); _Ping.Interval = 1000; _Ping.Elapsed += Ping; _Ping.Start(); } catch (Exception e) { Log.Error("RpcClient", "Erreur :" + e.ToString()); } return(true); }
public static object New(Type type) { if (types == null) { InitTypeTable(); } WellKnownClientTypeEntry entry = (WellKnownClientTypeEntry)types[type]; if (entry == null) { throw new RemotingException("Type not found!"); } return(RemotingServices.Connect(type, entry.ObjectUrl)); }
internal Client () { #if NET_2_0 ChannelServices.RegisterChannel (new TcpChannel (), false); #else ChannelServices.RegisterChannel (new TcpChannel ()); #endif WellKnownClientTypeEntry remotetype = new WellKnownClientTypeEntry (typeof (Service), "tcp://localhost:8082/TcpService"); RemotingConfiguration.RegisterWellKnownClientType (remotetype); service = new Service (); }
public void Run() { AllocConsole(); // Create the channel. TcpChannel clientChannel = new TcpChannel(); // Register the channel. ChannelServices.RegisterChannel(clientChannel, true); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry( typeof(ConsoleLoggerProxy), "tcp://localhost:9090/LoggerProxy.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = clientChannel.CreateMessageSink( "tcp://localhost:" + TcpController.Port + "/LoggerProxy.rem", null, out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Create an instance of the remote object. ConsoleLoggerProxy service = new ConsoleLoggerProxy(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); while (true) { while (service.Count > 0) { Console.WriteLine(service.Dequeue()); } } }
public static Object GetObject(Type type) { if (!_isInit) { InitTypeCache(); } WellKnownClientTypeEntry entr = (WellKnownClientTypeEntry)_wellKnownTypes[type]; if (entr == null) { throw new RemotingException("Type not found!"); } return(Activator.GetObject(entr.ObjectType, entr.ObjectUrl)); }
public static object GetObject(Type type) { if (!_isInit) { InitTypeCache(); } WellKnownClientTypeEntry entry = (WellKnownClientTypeEntry)_wellKnownTypes[type]; if (entry == null) { throw new RemotingException(string.Format("Type '{0}' not found.", type.Name)); } return(RemotingServices.Connect(entry.ObjectType, entry.ObjectUrl)); }
static public IPCCommunication InitClient <T>() { if (_t != null) { return(_t); } _t = new IPCCommunication(); IpcChannel channel = new IpcChannel(); ChannelServices.RegisterChannel(channel, false); WellKnownClientTypeEntry remotEntry = new WellKnownClientTypeEntry(_t.type = typeof(T), "ipc://AudioChannel/Player"); RemotingConfiguration.RegisterWellKnownClientType(remotEntry); return(_t); }
public static object New(Type type) { if (_types == null) { InitTypeTable(); } Debug.Assert(_types != null, "types != null"); // Added it WellKnownClientTypeEntry entry = (WellKnownClientTypeEntry)_types[type]; if (entry == null) { throw new RemotingException("Type not found!"); } return(RemotingServices.Connect(type, entry.ObjectUrl)); }
public static void GetService(string server, int port, Type type) { try { var url = "http://" + server + ":" + port + "/" + type.Name + ".rem"; TraceOps.Out("Try to get service : " + url); var remoteType = new WellKnownClientTypeEntry(type, url); remoteType.ApplicationUrl = url; TraceOps.Out(remoteType.ObjectUrl); RemotingConfiguration.RegisterWellKnownClientType(remoteType); } catch (Exception exception) { TraceOps.Out(exception.ToString()); } }
public static void OpenClientChannel(IEditorClientCallback client) { // Create a new channel on a separate port (this is used for the callbacks) ClientChannel = CreateChannel(ClientPortName); // Register as client for remote object. var remoteType = new WellKnownClientTypeEntry(typeof(EditorService), ServerUrl); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create an instance of the remote object. Service = Activator.GetObject(typeof(EditorService), ServerUrl) as EditorService; // Register the callback Service.Init(client); }
/// <summary> /// Registers interprocess communication client channel and the <see cref="IpcService"/> object proxy. /// </summary> private static void RegisterIpcClient() { // Unregister the channel if it was previously registered but the underlying pipe has been closed (e.g. when the service was restarted but the GUI wasn't). if (_channel != null) { ChannelServices.UnregisterChannel(_channel); } _channel = new IpcClientChannel(); ChannelServices.RegisterChannel(_channel, false); if (_service == null) { WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(IpcService), "ipc://RoboBackup/ipc"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); _service = new IpcService(); } }
public void Load() { Log.Info("RpcClient", "Loading"); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in assembly.GetTypes()) { if (!type.IsClass) { continue; } if (!type.IsSubclassOf(typeof(ARpc))) { continue; } object[] attrib = type.GetCustomAttributes(typeof(RpcAttributes), true); if (attrib.Length <= 0) { continue; } RpcAttributes[] packethandlerattribs = (RpcAttributes[])type.GetCustomAttributes(typeof(RpcAttributes), true); if (packethandlerattribs.Length <= 0) { continue; } foreach (string auth in packethandlerattribs[0].Authorised) { if (auth.StartsWith(_Name)) { Log.Debug("RpcClient", "Registering class : " + type.Name); WellKnownClientTypeEntry remotetype = new WellKnownClientTypeEntry(type, "tcp://" + _Ip + ":" + _Port + "/" + type.Name + _Id + _Key); RemotingConfiguration.RegisterWellKnownClientType(remotetype); break; } } } } }
public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry) { }