-1

I've created a simple C# remoting server/client with the view of replicating an existing VB6 ActiveX exe.

The client creates a server activated singleton object correctly. The object is only very simple having the one property - a Count. Each client that runs creates the object and increments its Count.

Simple - multiple clients are each working with the same Simpleton object and the Count property can be incremented by each.

However... if I leave a client open for any length of time - say, for example, a couple of minutes - when it the client increments the object's Count property, suddenly the Count property has been initialised to zero - across all clients. It's as though the remote object has been destroyed and recreated despite the object only ever being retrieved from the server once - when the client opens.

Any thoughts appreciated,

Thanks MM

Muckers Mate
  • 399
  • 8
  • 23
  • can you declare count as static variable, or application variable as it is share-able across all other instances – A.T. Nov 07 '13 at 11:34
  • 2
    Can you show us some of the relevant code? – rhughes Nov 07 '13 at 11:35
  • Can you show us some code so what we can give you a mode detailed answer? – Inkey Nov 07 '13 at 11:35
  • where are your client and server processes running? IIS for instance may restart the app-domain, so that your singleton is destroyed and recreated with a "count" of 0 – Paolo Falabella Nov 07 '13 at 11:39

1 Answers1

1

I believe you need to override the lifetime of the remote object:

public override object InitializeLifetimeService()
    {
        return null; //remote object lease time forever
    }

Place that into your class which inherits MarshalByRefObject

Nikeah
  • 40
  • 6