Wellknown-Singleton object is being created 2 times

P

polism

Hi,
I have a singleton class which I want to "create" (call it's
GetInstance() for the first time)
in server process, and after some time I want to use it in client
process, through .Net Remoting.
I define the singleton as MarshalByRefObject.

My server process looks like this:
1.Register singelton type as being wellknown singleton (not
singlecall).
2. Singleton.GetInstance()
3. Console.Write("Singleton constructor called");
4. do some logic inside the singleton
5. Wait for clients to connect

Client process looks like this:
1. Register singleton type.
2. Singleton.GetInstance()
After this call, "Singleton constructor called" is being printed AGAIN
on the screen,
which means that the singleton object is being created again, and thats
not what I want.
I want to receive proxy to the same singelton, already created in
server process.

I don't understand what I do wrong.
Please help,

Mike.
 
G

Guest

Hi Mike,

After step 2. Singleton.GetInstance(), you should call
RemotingServices.Marshal()
to register your singleton object.

For an example check out MSDN:
ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconremotingexampletrackingservice.htm

Tran, Dinh Duy
[MCSD/CSDP]
 
P

polism

Thanx, good point.
Unfortunately most literature on remoting forgets to mention this
simple rule.
 

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