static void Main(string[] args) { ConfigurationsHelper.HostApplicationName = string.Concat("Fwk remoting ", Fwk.Bases.ConfigurationsHelper.HostApplicationName); RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false); //RemotingHelper.WriteLog("Servicio de host de Remoting iniciado.", EventLogEntryType.Information); Fwk.Logging.Event ev = new Event(); ev.LogType = EventType.Information; ev.Machine = Environment.MachineName; ev.User = Environment.UserName; WellKnownClientTypeEntry[] myEntries = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); ev.Message.Text = "Servicio de Remoting consola iniciado."; StringBuilder str = new StringBuilder(); str.AppendLine(Fwk.Bases.ConfigurationsHelper.HostApplicationName); str.AppendLine(ev.Message.Text); Console.WriteLine(str.ToString()); try { StaticLogger.Log(TargetType.WindowsEvent, ev, null, null); } catch { } Console.ReadLine(); }
public static void InitTypeCache() { try { Configure(AppDomain.CurrentDomain.BaseDirectory.EndsWith(@"\") ? AppDomain.CurrentDomain.BaseDirectory + "Remoting.Config" : AppDomain.CurrentDomain.BaseDirectory + @"\Remoting.Config"); } catch (RemotingException) { //adding this for web apps because the base directory is not the bin folder string path = AppDomain.CurrentDomain.BaseDirectory; if (path.EndsWith(@"\")) { path += @"\"; } Configure(path + @"bin\Remoting.config"); } _wellKnownTypes = new Hashtable(); WellKnownClientTypeEntry[] entries = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); foreach (WellKnownClientTypeEntry entry in entries) { try { _wellKnownTypes.Add(entry.ObjectType, entry); } catch { throw new RemotingException(string.Format("Error occurred processing registered well known client types. The following configuration entry is not well formed: {0}", entry.ToString())); } } _isInit = true; }
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 clients = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); if (clients.Length == 0) { Console.WriteLine("You must specify app.config file with wellknown tag inside a client tag."); Console.ReadLine(); return; } 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 central = (ICentralManager)Activator.GetObject(clients[0].ObjectType, clients[0].ObjectUrl); var broker = new Broker(central); ObjRef objrefWellKnown = RemotingServices.Marshal(broker, services[0].ObjectUri); Console.WriteLine("Início do Server Broker.\n Espera de pedidos"); Console.ReadLine(); }
public BarcodeAdditionForm(BarcodeDetailsForm bf) { InitializeComponent(); ConnectionString = ConfigurationManager.ConnectionStrings["DBServerConnectionString"].ToString(); brdao = new BarcodeReaderDAO(ConnectionString); ldao = new LaminatorDAO(ConnectionString); btdao = new BarcodeTransactionDAO(ConnectionString); bcdf = bf; udao = new UserDAO(ConnectionString); DeviceIP = Dns.GetHostEntry(Dns.GetHostName()).AddressList.AsEnumerable().Where(s => s.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).Select(s => s).First().ToString(); PopulateBarcodeReaderDD(); if (ChannelServices.RegisteredChannels.Count <IChannel>() <= 0) { ChannelServices.RegisterChannel(new ChannelSrvc(new HttpChannel(), true), true); } IEnumerable a = RemotingConfiguration.GetRegisteredWellKnownClientTypes().AsEnumerable(); if (!RemotingConfiguration.GetRegisteredWellKnownClientTypes().AsEnumerable().Where(s => s.ObjectUrl == "http://" + ConfigurationManager.AppSettings["RemoteServerIP"].ToString() + ":" + ConfigurationManager.AppSettings["RemoteServerPort"] + "/ExcelReportUpdateUtility").Select(s => s).Any()) { RemotingConfiguration.RegisterWellKnownClientType(new WellKnownClientTypeEntry(typeof(ExcelReportUpdateUtility), "http://" + ConfigurationManager.AppSettings["RemoteServerIP"].ToString() + ":" + ConfigurationManager.AppSettings["RemoteServerPort"] + "/ExcelReportUpdateUtility")); } eru = new ExcelReportUpdateUtility(); eru.SetClientSystemIP(DeviceIP); }
private void button1_Click(object sender, EventArgs e) { try { RemotingConfiguration.Configure("channels.config", true); var aaa = ChannelServices.RegisteredChannels[0] as IChannelSender; var s3 = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); talk = (ILog)Activator.GetObject(typeof(ILog), s3[0].ObjectUrl); var ss = talk.Ping("Hello"); MessageBox.Show("连接成功。\r\n" + ss); button1.Enabled = false; } catch (RemotingException ex) { MessageBox.Show("连接失败。" + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
static Server() { RemotingConfiguration.Configure(_configFile, false); WellKnownClientTypeEntry[] entries = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); Console.WriteLine(entries[0].TypeName + " " + entries[0].ObjectType + " " + entries[0].ObjectUrl); _manager = (IManager)Activator.GetObject(entries[0].ObjectType, entries[0].ObjectUrl); }
static void Main(string[] args) { RemotingConfiguration.Configure("CP07_RemotingConfiguration.exe.config", false); var types = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); foreach (var clientTypeEntry in types) { Console.WriteLine("AssemblyName: {0}", clientTypeEntry.AssemblyName); Console.WriteLine("ObjectType: {0}", clientTypeEntry.ObjectType); Console.WriteLine("TypeName: {0}", clientTypeEntry.TypeName); } IAccount bankAccount = new BankAccount(); const int depositeCount = 3; decimal depositeAmount = 123; for (int i = depositeCount; i > 0; i--) { depositeAmount *= i; bankAccount.Deposite(depositeAmount); Console.WriteLine("Client: {0} deposite: {1}$.", bankAccount.Owner, depositeAmount); Console.WriteLine("Server: {0} balance: {1}$.", bankAccount.Owner, bankAccount.Balance); } Console.WriteLine("Client stop loop. Press any key to exit."); Console.ReadKey(); }
/// <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 RegisterWellKnownType() { TcpChannel chn = null; try { chn = new TcpChannel(1234); ChannelServices.RegisterChannel(chn); // register the SAO if(RemotingConfiguration.ApplicationName == null) RemotingConfiguration.ApplicationName = "RemotingConfigurationTest"; RemotingConfiguration.RegisterWellKnownServiceType(typeof(DerivedWellKnownObject), "WellKnownObject.rem", WellKnownObjectMode.Singleton); // get the registered services WellKnownServiceTypeEntry[] ast = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); bool IsServerRegistered = false; foreach(WellKnownServiceTypeEntry aste in ast) { if(aste.ObjectType == typeof(DerivedWellKnownObject)) { IsServerRegistered = true; break; } } Assert.IsTrue(IsServerRegistered, "#A02"); // register the client RemotingConfiguration.RegisterWellKnownClientType(typeof(WellKnownObject), "tcp://localhost:1234/"+RemotingConfiguration.ApplicationName+"/WellKnownObject.rem"); // get the registered client WellKnownClientTypeEntry[] act = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); bool IsClientRegistered = false; foreach(WellKnownClientTypeEntry acte in act) { if(acte.ObjectType == typeof(WellKnownObject)) { IsClientRegistered = true; break; } } Assert.IsTrue(IsClientRegistered, "#A03"); WellKnownObject objWellKnown = new WellKnownObject(); Assert.IsTrue(objWellKnown != null, "#A04"); Assert.IsTrue(RemotingServices.IsTransparentProxy(objWellKnown), "#A05"); objWellKnown.Method1(); Assert.IsTrue(objWellKnown.Method1Called, "#A06"); } finally { ChannelServices.UnregisterChannel(chn); } }
private static void InitTypeTable() { _types = new Hashtable(); foreach (WellKnownClientTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { _types.Add(entry.ObjectType ?? throw new InvalidOperationException(), entry); } }
private static void InitTypeTable() { types = new Hashtable(); foreach (WellKnownClientTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { types.Add(entry.ObjectType, entry); } }
public static void MostrarTodosLosDatos() { Log.Imprimir("TIPOS DE DATOS REGISTRADOS EN REMOTING -(INICIO)- ---------"); MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredActivatedClientTypes()); MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredActivatedServiceTypes()); MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredWellKnownClientTypes()); MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredWellKnownServiceTypes()); Log.Imprimir("TIPOS DE DATOS REGISTRADOS EN REMOTING -(FIN)- ---------"); }
public static void InitTypeCache() { _wellKnownTypes = new Hashtable(); foreach (WellKnownClientTypeEntry entr in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { _wellKnownTypes.Add(entr.ObjectType, entr); } }
static void VerifyRemotingConfiguration() { foreach (WellKnownClientTypeEntry en in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { if (en.ObjectType == null) { throw new Exception("Could not find type " + en.TypeName + " in assembly " + en.AssemblyName); } } }
public static void InitTypeCache() { Hashtable types = new Hashtable(); foreach (WellKnownClientTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { if (entry.ObjectType == null) throw new RemotingException("A configured type could not be found!"); types.Add(entry.ObjectType, entry); } wellKnownTypes = types; }
public static void DumpAllInfoAboutRegisteredRemotingTypes() { Log.Print("ALL REGISTERED TYPES IN REMOTING -(BEGIN)---------"); DumpTypeEntries(RemotingConfiguration.GetRegisteredActivatedClientTypes()); DumpTypeEntries(RemotingConfiguration.GetRegisteredActivatedServiceTypes()); DumpTypeEntries(RemotingConfiguration.GetRegisteredWellKnownClientTypes()); DumpTypeEntries(RemotingConfiguration.GetRegisteredWellKnownServiceTypes()); Log.Print("ALL REGISTERED TYPES IN REMOTING -(END) ---------"); }
static void Main(string[] args) { RemotingConfiguration.Configure(@"RPC.ServiceController.exe.config"); WellKnownClientTypeEntry[] clientEntry = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); IService hbService = Activator.GetObject(typeof(IService), clientEntry[0].ObjectUrl) as IService; hbService.Start(); Console.ReadLine(); }
private static void InitTypeTable() { types = new Hashtable(); WellKnownClientTypeEntry[] ar = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); foreach (WellKnownClientTypeEntry entry in ar) { //Type tp = Type.GetType(entry.TypeName); types.Add(entry.ObjectType, entry); } }
public static T GetRemotingServiceSys <T>(string objecturl) { foreach (WellKnownClientTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { if (entry.ObjectType == typeof(T) && entry.ObjectUrl == objecturl) { return((T)Activator.GetObject(typeof(T), ServerIPSys + entry.ObjectUrl)); } } return(default(T)); }
//Metodo de impresion de datos public static void MostrarTodosLosDatos() { Log.Imprimir("TIPOS DE DATOS REGISTRADOS EN REMOTING -(INICIO)- --------"); //Recupera una matriz de tipos de objetos registrados en el extremo de servicios //que puede activarse a petición de un cliente. MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredActivatedClientTypes()); MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredActivatedServiceTypes()); //Recupera una matriz de tipos de objetos registrados en el cliente final como tipos conocidos. MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredWellKnownClientTypes()); MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredWellKnownServiceTypes()); Log.Imprimir("TIPOS DE DATOS REGISTRADOS EN REMOTING -(FIN)- ---------"); }
public static object CreateWellKnownType(string typeName) { WellKnownClientTypeEntry[] entries = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); foreach (WellKnownClientTypeEntry entry in entries) { if (string.Equals(entry.TypeName, typeName)) { return(Activator.GetObject(Type.GetType(typeName), entry.ObjectUrl)); } } return(null); }
//The real hand-shaking among agents is performed inside this code. //The list of agents primarily their location is stored in a application //configuration file as part of remoting section, after reading this //location values with help of remoting helper method we enter //inside a foreach loop. It is inside this loop a remote instance //of agent is created on remote server and its reference is stored for //subsequent access. After successful creation of agent the next step //is to assign it the list of applications that are directly under its supervision. public void ConnectAgents() { foreach (WellKnownClientTypeEntry clientEntry in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { Console.WriteLine("Connecting to Agent : " + clientEntry.ObjectUrl); IController agent = Activator.GetObject(typeof(IController), clientEntry.ObjectUrl) as IController; agent.InitializeDataBag(dataBag); AgentInfo agentInfo = new AgentInfo(agent); agents[clientEntry.ObjectUrl] = agentInfo; InitializeApplications(agentInfo); } }
public static void Main() { try { RemotingConfiguration.Configure("EmployeeTrainingClient.exe.config", false); WellKnownClientTypeEntry[] client_types = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); IEmployeeTraining employee_training = (IEmployeeTraining)Activator.GetObject(typeof(IEmployeeTraining), client_types[0].ObjectUrl); EmployeeTrainingClient client = new EmployeeTrainingClient(employee_training); Application.Run(client); }catch (Exception e) { Console.WriteLine(e); } }
private static bool TryGetClientType(string typeName, ref string url) { WellKnownClientTypeEntry[] entries = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); foreach (WellKnownClientTypeEntry entry in entries) { if (string.Equals(entry.TypeName, typeName)) { url = entry.ObjectUrl; return(true); } } return(false); //Not found }
public static void Main() { try { RemotingConfiguration.Configure("client.config", false); WellKnownClientTypeEntry[] client_types = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); ITest test = (ITest)Activator.GetObject(typeof(ITest), client_types[0].ObjectUrl); Console.WriteLine(test.Text); test.Text = "This is a new string sent from the client application"; Console.WriteLine(test.Text); }catch (Exception e) { Console.WriteLine(e); } }
/// <summary> /// Liest die registrierten Typen aus der Remoting-Konfiguration /// und speichert diese für den schnellen Zugriff zwischen. /// </summary> /// <exception cref="RemotingException">Gefundener Typ nicht gefunden</exception> private static void Initialize() { s_wellKnownTypes = new Dictionary <Type, WellKnownClientTypeEntry>(); foreach (WellKnownClientTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownClientTypes()) { if (entry.ObjectType == null) { RemotingException ex = new RemotingException("Object type for type " + ((entry.TypeName != null) ? entry.TypeName : "(null)") + " could not be found. Check spelling in RemotingClient.config."); throw ex; } s_wellKnownTypes.Add(entry.ObjectType, entry); } }
static void Main() { // Load the configuration file RemotingConfiguration.Configure("TransactionManager.exe.config", false); WellKnownClientTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); string url = string.Empty; foreach (WellKnownClientTypeEntry tp in wkst) { if (tp.ObjectUrl.EndsWith("TransactionFactory")) { url = tp.ObjectUrl; } Console.WriteLine(tp.ObjectUrl); } ITransactionFactory factory = null; if (url.Length > 0) { factory = (ITransactionFactory)RemotingServices.Connect( typeof(ITransactionFactory), url); } else { Console.WriteLine("Could not find requested object!!!"); } if (factory != null) { try { // Function to test if remoting is working correctly... string testStr = factory.Test(); } catch (Exception ex) { string exMsg = ex.Message; string innerMsg = ex.InnerException.Message; } Console.WriteLine(factory.Test()); Console.WriteLine(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TransactionManager(factory)); } }
public static void Main(){ try { RemotingConfiguration.Configure("client.config", false); WellKnownClientTypeEntry[] client_types = RemotingConfiguration.GetRegisteredWellKnownClientTypes(); ITest test = (ITest)Activator.GetObject(typeof(ITest), client_types[0].ObjectUrl ); Console.WriteLine(test.Text); for(int i=0; i<100; i++){ test.Text = "This is string number " + i + " sent from the client application"; Console.WriteLine(test.Text); Thread.Sleep(3000); } }catch(Exception e){ Console.WriteLine(e); } }
// Método que recupera la información acerca del tipo de los objetos definidos, configurados // para el programa que usa net remoting public static void MostrarTodosLosDatos() { Log.Imprimir("TIPOS DE DATOS REGISTRADOS EN REMOTING -(INICIO)- ---------"); // Recupera los tipos de objetos registrados en el cliente como tipos que se activarán // de forma remota MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredActivatedClientTypes()); // Recupera los tipos de objetos registrados en el servicio que se pueden activar // cuando lo solicita un cliente. MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredActivatedServiceTypes()); // Recupera los tipos de objetos registrados en el cliente como tipos conocidos (WellKnown) MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredWellKnownClientTypes()); // Recupera los tipos de objetos registrados en el servicio como tipos conocidos (WellKnown) MostrarTipoDeDatos(RemotingConfiguration.GetRegisteredWellKnownServiceTypes()); Log.Imprimir("TIPOS DE DATOS REGISTRADOS EN REMOTING -(FIN)- ---------"); }