Remoting Problem

S

S Chapman

I have a simple remote server object that raises an event when the list
maintined by it changes. The idea is to enable the remote client to
update the GUI when the server list changes. When the I create the
server object without using remoting (i.e. just use new()) the event
fires and the client updates the UI but when I create the server object
as a remote object (using Activator.GetObject()) the event does not
fire at all. I have pasted the code below. I am pulling my hair out
trying to solve this simple problem. Any help will be much appreciated.
Thank you.

===================================================
Source Code from Remoting Host ( Console App)
===================================================

// Configure the Remoting Infrastructure
BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
Hashtable props = new Hashtable();
props["port"] = Facade.RemotingParameters.PORT;

// Register Channel first
System.Runtime.Remoting.Channels.Tcp.TcpServerChannel channel = new
System.Runtime.Remoting.Channels.Tcp.TcpServerChannel(props,provider);
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel,false);

// Use Server Activated and Singleton as the object mode
System.Type remoteType = typeof(BusinessLayer.Services);
RemotingConfiguration.RegisterWellKnownServiceType(remoteType ,
Facade.RemotingParameters.URI,
WellKnownObjectMode.Singleton);

===================================================
Source Code from Remoting Client (System.Windows.Forms App)
===================================================

// Register a Channel for Event Handler purposes.
ChannelServices.RegisterChannel(new TcpClientChannel(), false);

// Create the remote object
this._services =
(Facade.IServices)Activator.GetObject(typeof(Facade.IServices),
this._txtServer.Text);

// Add Event Handler
this._eventRepeater = new Facade.EventRepeater();
this._eventRepeater.ListChanged += this.ListChangedEventHandler;
this._services.ListChanged += _eventRepeater.ListChangedEventHandler;
 
A

Alan Samet

Is it possible that your Singleton server object is expiring? Have you
looked into the InitializeLifetimeService() method of
MarshalByRefObject?

-Alan
 
A

Alan Samet

I just pulled up some code I wrote a few years back that did what
you're trying to accomplish. I used a TcpChannel at port 0 on my client
instead of a TcpClientChannel. On my server, I had the
InitializeLifetimeService method overridden as follows:

public override object InitializeLifetimeService()
{
return null;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top