.Net remoting, registering two channel? how???
-
Hello, I've got an application that needs to create 2 remote object (CAO type), I init them into businness logic level:
private void InitNetRemotingProxy() { myDataProxyAccess = new ProxyDataAccess(idCup, idSeason, idMatchCode); myDataProxyAccess.InitNetRemotingClient("Normal"); myDataProxyAccessForLev1 = new ProxyDataAccess(idCup, idSeason, idMatchCode); myDataProxyAccess.InitNetRemotingClient("Lev1"); }
and here's where the init is donepublic void InitNetRemotingClient(string type) { string remotingConnection = system.Configuration.ConfigurationManager.AppSettings["serverAddress"]; string tcpPort = (type!="Lev1") ? System.Configuration.ConfigurationManager.AppSettings["tcpPort"] : System.Configuration.ConfigurationManager.AppSettings["tcpPortLev1Stat"]; string requestService = (type != "Lev1") ? System.Configuration.ConfigurationManager.AppSettings["requestServiceName"] : System.Configuration.ConfigurationManager.AppSettings["requestServiceName2"]; string sb = String.Format("tcp://{0}:{1}/{2}", remotingConnection, tcpPort, requestService); try { RemotingConfiguration.IsRemotelyActivatedClientType(typeof(DBHelper)); IChannel ic = new TcpChannel(Convert.ToInt32(tcpPort)); int i = 0; ChannelServices.RegisterChannel(ic, false); RemotingConfiguration.RegisterActivatedClientType(typeof(DBHelper), sb); myDBHelper = new DBHelper(idCup, idSeason, idMatchCode); }
on the second call, the onemyDataProxyAccess.InitNetRemotingClient("Lev1");
I get an exception at ChannelServices.RegisterChannel(ic, false);, the exception is : Message = "The channel 'tcp' is already registered.". It's not possible to create 2 channel? Where I do wrong? The tcpport and requestServiceName are different for the two calls. Please help me, thanks Bests Paolo Ponzano -
Hello, I've got an application that needs to create 2 remote object (CAO type), I init them into businness logic level:
private void InitNetRemotingProxy() { myDataProxyAccess = new ProxyDataAccess(idCup, idSeason, idMatchCode); myDataProxyAccess.InitNetRemotingClient("Normal"); myDataProxyAccessForLev1 = new ProxyDataAccess(idCup, idSeason, idMatchCode); myDataProxyAccess.InitNetRemotingClient("Lev1"); }
and here's where the init is donepublic void InitNetRemotingClient(string type) { string remotingConnection = system.Configuration.ConfigurationManager.AppSettings["serverAddress"]; string tcpPort = (type!="Lev1") ? System.Configuration.ConfigurationManager.AppSettings["tcpPort"] : System.Configuration.ConfigurationManager.AppSettings["tcpPortLev1Stat"]; string requestService = (type != "Lev1") ? System.Configuration.ConfigurationManager.AppSettings["requestServiceName"] : System.Configuration.ConfigurationManager.AppSettings["requestServiceName2"]; string sb = String.Format("tcp://{0}:{1}/{2}", remotingConnection, tcpPort, requestService); try { RemotingConfiguration.IsRemotelyActivatedClientType(typeof(DBHelper)); IChannel ic = new TcpChannel(Convert.ToInt32(tcpPort)); int i = 0; ChannelServices.RegisterChannel(ic, false); RemotingConfiguration.RegisterActivatedClientType(typeof(DBHelper), sb); myDBHelper = new DBHelper(idCup, idSeason, idMatchCode); }
on the second call, the onemyDataProxyAccess.InitNetRemotingClient("Lev1");
I get an exception at ChannelServices.RegisterChannel(ic, false);, the exception is : Message = "The channel 'tcp' is already registered.". It's not possible to create 2 channel? Where I do wrong? The tcpport and requestServiceName are different for the two calls. Please help me, thanks Bests Paolo PonzanoI've fixed it, I've used:
IDictionary pros = new Hashtable(); pros["port"] = tcpPort; pros["name"] = type; IChannel ic = new TcpChannel(pros, null, null);
and I had to substituteRemotingConfiguration.RegisterActivatedClientType(typeof(DBHelper), sb);
withRemotingServices.Connect(typeof (DBHelper), sb);
Seems to work, do you know if there's still something I've to do? Thanks