Well-known server activated object and IDisposable

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Hani Atassi (hani_at_community.nospam)
Date: 06/17/04


Date: Thu, 17 Jun 2004 09:51:06 -0700

I created a singleton object using .NET Remoting. The object is created in a .NET remoting server and the same instance is marshaled to the client when the client creates a new object of it.

This singleton object is hosted under NTService and I need to destroy it when the service is stopped and create it again when the service is started. So, I thought I would implement the IDisposable interface on the class using the Disposable Pattern to clean the resources that I am using inside it.

But, what if the client called Dispose() or the client uses the using(){} keyword? In this case the cleanup code in the server will be executed which will result in unpleasant behavior from the other connected clients.

So, is it OK to implement IDisposable in my scenario or how can I prevent the client code from calling Dispose()?.. Is there a way to know if the call to the function came from a client or came from the remoting server? I tried RemotingServices.IsObjectOutOfAppDomain(this) but it always returns false if it's executed in the server..!

Any help is appreciated..

Thanks,



Relevant Pages

  • Remoting objects lifetime?
    ... I created a singleton object using .NET Remoting. ... ..NET remoting server and the same instance is marshaled to the client when ... the client creates a new object of it. ...
    (microsoft.public.dotnet.framework.remoting)
  • RE: Distributed application programming
    ... the .net remoting will do many of the thread schedule ... time, what you have to do is build a server and client application, all the ... client will try to post request to the server and then the server process ... I would just recommend to use and tune the thread pool provided by the clr: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: P2P Chat w/Web Services
    ... > The thing I need to figure out is how a c# windows form client can expose ... > Is there an easy way to put a web services method into a regular client ... Web Service is just like a web site except that it doesn't return HTML code ... And here comes .NET Remoting: with .NET Remoting, you can do all that you ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: remoting newbie
    ... I know very little about .net remoting but it sounds like a potential ... Take a look at WCF too, I've been meaning to start using it. ... all other users see the change on their own client immediatly. ... Are the changes to the data tables stored to the database? ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Thread affinity
    ... ..NET Remoting has no built in support for thread affinity. ... So creating a thread for each client is feasible. ... Also requirement is http/channel for maximum portability. ...
    (microsoft.public.dotnet.framework.clr)