HighTechTalks DotNet Forums  

Remoting SAO help

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss Remoting SAO help in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ryan
 
Posts: n/a

Default Remoting SAO help - 01-26-2007 , 02:51 PM






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


Reply With Quote
  #2  
Old   
Robson Siqueira
 
Posts: n/a

Default Re: Remoting SAO help - 01-27-2007 , 02:43 PM






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" <rchill81 (AT) gmail (DOT) com> wrote

Quote:
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




Reply With Quote
  #3  
Old   
Ryan
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 08:11 AM



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:
Quote:
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 -


Reply With Quote
  #4  
Old   
Robson Siqueira
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 10:29 AM



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(thisServer);
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" <rchill81 (AT) gmail (DOT) com> wrote

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:
Quote:
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 -



Reply With Quote
  #5  
Old   
Ryan
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 11:40 AM



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:
Quote:
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 -


Reply With Quote
  #6  
Old   
Robson Siqueira
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 12:12 PM



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" <rchill81 (AT) gmail (DOT) com> wrote

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:
Quote:
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 -



Reply With Quote
  #7  
Old   
Ryan
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 12:45 PM



Robson,

I'm getting "can't find the assembly" message when I try to read my
remoted object. I'm unclear as where the problem is. Any thoughts?

On Jan 29, 12:12 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote:
Quote:
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 -


Reply With Quote
  #8  
Old   
Robson Siqueira
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 12:51 PM



Without your code - or a piece of it - it will be very complicated to help
you.

Besides, try implement your remoteable object over a interface. It makes a
way easier to work with things.

--
Regards,
Robson Siqueira
Enterprise Architect
"Ryan" <rchill81 (AT) gmail (DOT) com> wrote

Robson,

I'm getting "can't find the assembly" message when I try to read my
remoted object. I'm unclear as where the problem is. Any thoughts?

On Jan 29, 12:12 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote:
Quote:
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 -



Reply With Quote
  #9  
Old   
Ryan
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 12:51 PM



I'm also not using interfaces. I'm not sure if I need to or not.
Could that be an/the issue?

On Jan 29, 12:12 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote:
Quote:
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 -


Reply With Quote
  #10  
Old   
Robson Siqueira
 
Posts: n/a

Default Re: Remoting SAO help - 01-29-2007 , 12:57 PM



Remember that when you are marshalling your object directly, the other peer
needs to know the type. It is easier to deal with these situations using an
interface. By then your interface would be shared between your two
applications. It make things a WAY easier.

--
Regards,
Robson Siqueira
Enterprise Architect
"Ryan" <rchill81 (AT) gmail (DOT) com> wrote

I'm also not using interfaces. I'm not sure if I need to or not.
Could that be an/the issue?

On Jan 29, 12:12 pm, "Robson Siqueira" <rob... (AT) robsonfelix (DOT) com> wrote:
Quote:
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 -



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.