Hi
I included some code snippets for illustration
if i start the server app and wait some time before starting the client then
if fails with an exception on the client program.
(saying i need to turn off customErrors ....? )
If i call the methods on a regular basis then no problems..
/////////////// CODE ON SERVER PART (remote display
/////////////////////////
public partial class Form1 : Form
{
....
private Display rmDisplay;
....
#region init code
public Form1()
{
InitializeCompo nent();
// Register our tcp channel
ChannelServices .RegisterChanne l(new TcpChannel(5005 0), false);
// Register an object created by the server
rmDisplay = new Display();
ObjRef refDisplay = RemotingService s.Marshal(rmDis play,
"Display");
rmDisplay.RtfMe ssagebox = this.rtb_meldin gen; // pass the
richtextbox on the form to the Display class
rmDisplay.Contr olOwner = this; // needed for Control.Invoke
rmDisplay.SetDi splayTiming += new
Display.SetDisp layTimingHandle r(rmDisplay_Set DisplayTiming);
rmDisplay.SetWo rkLoadEvent += new
Display.SetWork LoadHandler(rmD isplay_SetWorkL oadEvent);
rmDisplay.Incom ingEvent += new
Display.Incomin gEventHandler(r mDisplay_Incomi ngEvent);
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er
MyFormatter = new
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();
MyFormatter.Fil terLevel =
System.Runtime. Serialization.F ormatters.TypeF ilterLevel.Full ;
}
// rest of source cut
....
....
}
// snippet from display class
class Display : MarshalByRefObj ect
{
public RichTextBox RtfMessagebox;
public Control ControlOwner;
public delegate void SetDisplayTimin gHandler(object sender, int
displaylogo_tim eout,int displayoff_time out);
public event SetDisplayTimin gHandler SetDisplayTimin g;
public delegate void SetWorkLoadHand ler(object sender, int
workload);
public event SetWorkLoadHand ler SetWorkLoadEven t;
public delegate void IncomingEventHa ndler(object sender);
public event IncomingEventHa ndler IncomingEvent;
public Display()
{
}
delegate void SetTimesCallbac k(int displaylogo_tim eout, int
displayoff_time out);
// call its own if Control.Invoke is required to avoid cross thread
problems
public void SetTiming(int displaylogo_tim eout,int
displayoff_time out)
{
if (SetDisplayTimi ng != null)
{
if (ControlOwner.I nvokeRequired == false)
SetDisplayTimin g(this, displaylogo_tim eout,
displayoff_time out);
else
{
SetTimesCallbac k d = new SetTimesCallbac k(SetTiming);
ControlOwner.In voke(d, new object[] {
displaylogo_tim eout, displayoff_time out });
}
}
}
//rest of code cut
...
...
}
///////////////////// CODE on CLient app. (app controlling the remote
display)
// this function is used on the remote client to call the method on the
server
private void SetTimeLimits(i nt t_logo,int t_poweroff)
{
TcpClientChanne l displaych2 = new TcpClientChanne l();
ChannelServices .RegisterChanne l(displaych2, false);
Display rDisplay;
rDisplay = (Display)Activa tor.GetObject(t ypeof(Display),
"tcp://192.168.1.3:500 50/Display");
rDisplay.SetTim ing(t_logo, t_poweroff);
ChannelServices .UnregisterChan nel(displaych2) ;
}
"Altaf Al-Amin Najwani" <al**********@g mail.com> wrote in message
news:85******** *************** ***********@mic rosoft.com...
Can you pls tell me is it Client Activated or Server Activated object? The
life time of Marshal by reference remote object is maintained by the
Lease, Lease Manager and several Sponsors. Lease defines the life time of the
remote object. You can either give long time duration for the remote object in
InitializeLifeT imeService or you can implement ISponsor Interface in
calling application and then override RenewLease() to solve this problem
"Sagaert Johan" wrote:
Hi
When the remoting server starts and the client immediate begins calling
the remote object on the server no problems.
But when the client does not need to access the remote object for some
time the connection seems to be broken on the next attempt to do a call to
the remote object on the server. (i need to restart the server application
to get it working again ).
So it appears if the remoting connection is idle for some time ( about a
minute max ) the connection seems to break.
When there are regular call it ran for a whole day without problems.
Any way i can fix this ?
Thanks ,
Johan
this is how i ini the remote server
// Register our tcp channel
ChannelServices .RegisterChanne l(new TcpChannel(sett ing.RemotePort) ,
false);
// Register an object created by the server
rmDisplay = new Display(); //inherits from MarshalByRefObj ect
ObjRef refDisplay = RemotingService s.Marshal(rmDis play, "Display");