The error is almost certainly due to the lifetime expiring for these
objects. If these objects are CAOs, then you don't want to overide
InitializeLifetimeService() in the same way unless you're managing their
lifetimes yourself on the server (e.g. you have a cleanup thread that calls
RemotingServices.Disconnect() on objects which haven't been accessed
recently).
Instead, you should use client-side sponsors to determine when you're done
with the object. Alternatively, you can code your client so it re-fetches
the object each time it's needed (i.e. don't hold onto references to the
remote for any extended period of time).
For more on using sponsors, check out:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconrenewingleases.asp Ken
[quoted text, click to view] "Stephane" <Stephane@discussions.microsoft.com> wrote in message
news:49C7E58F-2532-4379-BF1D-C6344101663E@microsoft.com...
> Hi,
>
> I wonder if every class has to override the InitializeLifetimeService
method
> in order to stay alive as long as we need it.
>
> public override object InitializeLifetimeService()
> {
> return null;
> }
>
> I ask this because my main application which is deriving from
> MarshalByRefObject has this method overidden. This server returns many
others
> objects like customers and visitors which also deriving from
> MarshalByRefObject but I didn't override the InitializeLifetimeService
method
> in those classes.
>
> Sometimes, I'm getting the error "Object </ blablabla.rem> has been
> disconnected or does not exist at the server" so I was wondering if this
is
> the cause of that disconnection.
>
> Should I override the InitializeLifetimeService method in every class
> deriving from MarshalByRefObject?
>
> Thanks
>
> Stephane
>