![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly().Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub |
#3
| |||
| |||
|
|
Ryan, Why don't you instantiate first your main object - the remotable object - and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()*.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text - |
#4
| |||
| |||
|
|
Ryan, Why don't you instantiate first your main object - the remotable object - and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()*.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text - |
#5
| |||
| |||
|
|
Ryan, The example would be: On the server ========= MyRemotableObject thisServer = new MyRemotableObject(); TcpChannel tcp = new TcpChannel(1234); ChannelServices.RegisterChannel(tcp, true); RemotingConfiguration.ApplicationName = "MyRemotableObject Server"; RemotingServices.Marshal(thisServer, "MyRemotableObject.rem"); while (!stopRequested) { // let's wait for requests Thread.Sleep(1000);}RemotingServices.Disconnect(th isServer); ChannelServices.UnregisterChannel(tcp); thisServer.Quit(); // my disposal method On your client ========== TcpChannel tcp = new TcpChannel(); ChannelServices.RegisterChannel(tcp, true); string ServerIP = "localhost"; IMyRemotableObject runServer = (IMyRemotableObject)Activator.GetObject(typeof(IMy RemotableObject), string.Concat("tcp://", ServerIP, ":1234/IMyRemotableObject.rem")); return runServer; Where runServer returns my already instantiated (SAO) remotable object. I hope it helps. -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170076305.390504.222190 (AT) m58g2000cwm (DOT) googlegroups.com... I understand what you're saying but I don't know too much about remoting. How do you instantiate the object then make it remoteable. I thought the GetObject method does but it only creates a new instance (I think??) Can you elaborate? On Jan 27, 2:43 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, Why don't you instantiate first your main object - the remotable object- and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()**.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text - |
#6
| |||
| |||
|
|
Ryan, The example would be: On the server ========= MyRemotableObject thisServer = new MyRemotableObject(); TcpChannel tcp = new TcpChannel(1234); ChannelServices.RegisterChannel(tcp, true); RemotingConfiguration.ApplicationName = "MyRemotableObject Server"; RemotingServices.Marshal(thisServer, "MyRemotableObject.rem"); while (!stopRequested) { // let's wait for requests Thread.Sleep(1000);}RemotingServices.Disconnect(th isServer); ChannelServices.UnregisterChannel(tcp); thisServer.Quit(); // my disposal method On your client ========== TcpChannel tcp = new TcpChannel(); ChannelServices.RegisterChannel(tcp, true); string ServerIP = "localhost"; IMyRemotableObject runServer = (IMyRemotableObject)Activator.GetObject(typeof(IMy RemotableObject), string.Concat("tcp://", ServerIP, ":1234/IMyRemotableObject.rem")); return runServer; Where runServer returns my already instantiated (SAO) remotable object. I hope it helps. -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170076305.390504.222190 (AT) m58g2000cwm (DOT) googlegroups.com... I understand what you're saying but I don't know too much about remoting. How do you instantiate the object then make it remoteable. I thought the GetObject method does but it only creates a new instance (I think??) Can you elaborate? On Jan 27, 2:43 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, Why don't you instantiate first your main object - the remotable object - and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()**.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text - |
#7
| |||
| |||
|
|
Ryan, Yes, the object needs to be serializable. About the disconnection, as far as I am concerned, in the way I implemented here, the only way is by disconnecting it manually. I am not aware of a mixed solution for this case, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170088810.102865.197690 (AT) a75g2000cwd (DOT) googlegroups.com... Does EVERY object have to be serializable? Since this is a service program, I wrote a console app to dupliate what the service does so I debug it without having to attach to the process. Its telling that that class is not serializable then when I did, it says it can't find the assembly. Well of course not because thats not whats being remote. Only the object. What am I doing wrong? Also, do you have to manually disconnect the tcp channel because I usa a config file. Can it be done inside the config file? On Jan 29, 10:29 am, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, The example would be: On the server ========= MyRemotableObject thisServer = new MyRemotableObject(); TcpChannel tcp = new TcpChannel(1234); ChannelServices.RegisterChannel(tcp, true); RemotingConfiguration.ApplicationName = "MyRemotableObject Server"; RemotingServices.Marshal(thisServer, "MyRemotableObject.rem"); while (!stopRequested) { // let's wait for requests Thread.Sleep(1000);}RemotingServices.Disconnect(th isServer); ChannelServices.UnregisterChannel(tcp); thisServer.Quit(); // my disposal method On your client ========== TcpChannel tcp = new TcpChannel(); ChannelServices.RegisterChannel(tcp, true); string ServerIP = "localhost"; IMyRemotableObject runServer = (IMyRemotableObject)Activator.GetObject(typeof(IMy RemotableObject), string.Concat("tcp://", ServerIP, ":1234/IMyRemotableObject.rem")); return runServer; Where runServer returns my already instantiated (SAO) remotable object. I hope it helps. -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170076305.390504.222190 (AT) m58g2000cwm (DOT) googlegroups.com... I understand what you're saying but I don't know too much about remoting. How do you instantiate the object then make it remoteable. I thought the GetObject method does but it only creates a new instance (I think??) Can you elaborate? On Jan 27, 2:43 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, Why don't you instantiate first your main object - the remotable object - and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()***.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text - |
#8
| |||
| |||
|
|
Ryan, Yes, the object needs to be serializable. About the disconnection, as far as I am concerned, in the way I implemented here, the only way is by disconnecting it manually. I am not aware of a mixed solution for this case, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170088810.102865.197690 (AT) a75g2000cwd (DOT) googlegroups.com... Does EVERY object have to be serializable? Since this is a service program, I wrote a console app to dupliate what the service does so I debug it without having to attach to the process. Its telling that that class is not serializable then when I did, it says it can't find the assembly. Well of course not because thats not whats being remote. Only the object. What am I doing wrong? Also, do you have to manually disconnect the tcp channel because I usa a config file. Can it be done inside the config file? On Jan 29, 10:29 am, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, The example would be: On the server ========= MyRemotableObject thisServer = new MyRemotableObject(); TcpChannel tcp = new TcpChannel(1234); ChannelServices.RegisterChannel(tcp, true); RemotingConfiguration.ApplicationName = "MyRemotableObject Server"; RemotingServices.Marshal(thisServer, "MyRemotableObject.rem"); while (!stopRequested) { // let's wait for requests Thread.Sleep(1000);}RemotingServices.Disconnect(th isServer); ChannelServices.UnregisterChannel(tcp); thisServer.Quit(); // my disposal method On your client ========== TcpChannel tcp = new TcpChannel(); ChannelServices.RegisterChannel(tcp, true); string ServerIP = "localhost"; IMyRemotableObject runServer = (IMyRemotableObject)Activator.GetObject(typeof(IMy RemotableObject), string.Concat("tcp://", ServerIP, ":1234/IMyRemotableObject.rem")); return runServer; Where runServer returns my already instantiated (SAO) remotable object. I hope it helps. -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170076305.390504.222190 (AT) m58g2000cwm (DOT) googlegroups.com... I understand what you're saying but I don't know too much about remoting. How do you instantiate the object then make it remoteable. I thought the GetObject method does but it only creates a new instance (I think??) Can you elaborate? On Jan 27, 2:43 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, Why don't you instantiate first your main object - the remotable object - and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()***.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text - |
#9
| |||
| |||
|
|
Ryan, Yes, the object needs to be serializable. About the disconnection, as far as I am concerned, in the way I implemented here, the only way is by disconnecting it manually. I am not aware of a mixed solution for this case, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170088810.102865.197690 (AT) a75g2000cwd (DOT) googlegroups.com... Does EVERY object have to be serializable? Since this is a service program, I wrote a console app to dupliate what the service does so I debug it without having to attach to the process. Its telling that that class is not serializable then when I did, it says it can't find the assembly. Well of course not because thats not whats being remote. Only the object. What am I doing wrong? Also, do you have to manually disconnect the tcp channel because I usa a config file. Can it be done inside the config file? On Jan 29, 10:29 am, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, The example would be: On the server ========= MyRemotableObject thisServer = new MyRemotableObject(); TcpChannel tcp = new TcpChannel(1234); ChannelServices.RegisterChannel(tcp, true); RemotingConfiguration.ApplicationName = "MyRemotableObject Server"; RemotingServices.Marshal(thisServer, "MyRemotableObject.rem"); while (!stopRequested) { // let's wait for requests Thread.Sleep(1000);}RemotingServices.Disconnect(th isServer); ChannelServices.UnregisterChannel(tcp); thisServer.Quit(); // my disposal method On your client ========== TcpChannel tcp = new TcpChannel(); ChannelServices.RegisterChannel(tcp, true); string ServerIP = "localhost"; IMyRemotableObject runServer = (IMyRemotableObject)Activator.GetObject(typeof(IMy RemotableObject), string.Concat("tcp://", ServerIP, ":1234/IMyRemotableObject.rem")); return runServer; Where runServer returns my already instantiated (SAO) remotable object. I hope it helps. -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170076305.390504.222190 (AT) m58g2000cwm (DOT) googlegroups.com... I understand what you're saying but I don't know too much about remoting. How do you instantiate the object then make it remoteable. I thought the GetObject method does but it only creates a new instance (I think??) Can you elaborate? On Jan 27, 2:43 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, Why don't you instantiate first your main object - the remotable object - and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()***.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text - |
#10
| |||
| |||
|
|
Ryan, Yes, the object needs to be serializable. About the disconnection, as far as I am concerned, in the way I implemented here, the only way is by disconnecting it manually. I am not aware of a mixed solution for this case, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170088810.102865.197690 (AT) a75g2000cwd (DOT) googlegroups.com... Does EVERY object have to be serializable? Since this is a service program, I wrote a console app to dupliate what the service does so I debug it without having to attach to the process. Its telling that that class is not serializable then when I did, it says it can't find the assembly. Well of course not because thats not whats being remote. Only the object. What am I doing wrong? Also, do you have to manually disconnect the tcp channel because I usa a config file. Can it be done inside the config file? On Jan 29, 10:29 am, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, The example would be: On the server ========= MyRemotableObject thisServer = new MyRemotableObject(); TcpChannel tcp = new TcpChannel(1234); ChannelServices.RegisterChannel(tcp, true); RemotingConfiguration.ApplicationName = "MyRemotableObject Server"; RemotingServices.Marshal(thisServer, "MyRemotableObject.rem"); while (!stopRequested) { // let's wait for requests Thread.Sleep(1000);}RemotingServices.Disconnect(th isServer); ChannelServices.UnregisterChannel(tcp); thisServer.Quit(); // my disposal method On your client ========== TcpChannel tcp = new TcpChannel(); ChannelServices.RegisterChannel(tcp, true); string ServerIP = "localhost"; IMyRemotableObject runServer = (IMyRemotableObject)Activator.GetObject(typeof(IMy RemotableObject), string.Concat("tcp://", ServerIP, ":1234/IMyRemotableObject.rem")); return runServer; Where runServer returns my already instantiated (SAO) remotable object. I hope it helps. -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1170076305.390504.222190 (AT) m58g2000cwm (DOT) googlegroups.com... I understand what you're saying but I don't know too much about remoting. How do you instantiate the object then make it remoteable. I thought the GetObject method does but it only creates a new instance (I think??) Can you elaborate? On Jan 27, 2:43 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote: Ryan, Why don't you instantiate first your main object - the remotable object - and then remote it? This is what I normally do when I need to perform the same thing you are trying to do. Best, -- Regards, Robson Siqueira Enterprise Architect"Ryan" <rchil... (AT) gmail (DOT) com> wrote in messagenews:1169841078.729810.148680 (AT) j27g2000cwj (DOT) googlegroups.com... I've written a windows service and service manager app that for works ok. The service contains a collection of objects that does all the work. What I would like to do is allow the service manager app gain access to read the collection on thats on the service. The service will do everything to collection but I'd like to use the service manager to "check in" on how the objects are doing. If one is disconnected or encountered an error. I'd figure I would setup my collection/object to be SAO. But on my client side I get an new object of the type instead of a reference of the object. Please help. Configuration configuration system.runtime.remoting application name="ToscastHostService" service wellknown type="Toscast.RemoteToscastObject,Toscast" objectUri="RemoteToscastObject" mode="Singleton" / /service channels channel ref="tcp" port="8085" serverProviders formatter ref="binary" / /serverProviders /channel /channels /application /system.runtime.remoting /configuration Service: *** For now, I just instantiate the object since I can't get the remoting to work. ' Add code here to start your service. This method should set things ' in motion so your service can do its work. 'RemotingConfiguration.Configure(Reflection.Assemb ly.GetExecutingAssembly()***.Location & ".config") m_remoteObj = New RemoteToscastObject Dim regKey As RegistryKey Dim data() As String Try regKey = Registry.LocalMachine.OpenSubKey(c_RegistryKey) If Not regKey.GetValue("Hosts") Is Nothing Then data = regKey.GetValue("Hosts", "") For Each s As String In data Dim ary() As String = s.Split("/") Dim tc As ToscastController = New ToscastController(ary(0), ary(1)) AddHandler tc.DataAvailable, AddressOf host_DataAvailable AddHandler tc.SocketError, AddressOf host_SocketError m_remoteObj.Hosts.Add(tc) tc.Connect("CTSAA", "CTMAA") Next End If Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub Client Service Manager: *** This only returns a copy of object, not a reference. Private Sub InitRemoting() Try Dim chan As TcpChannel = New TcpChannel ChannelServices.RegisterChannel(chan) remoteObj = Activator.GetObject(GetType(RemoteToscastObject), "tcp://localhost:8085/RemoteToscastObject") For Each t As ToscastController In remoteObj.Hosts Debug.WriteLine(t.MachineName) Next Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text - |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |