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.

RE: Wellknown-Singleton object is being created 2 times by DinhduyTran

DinhduyTran
Mon Nov 28 14:16:02 CST 2005

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]

"polism@gmail.com" wrote:

> 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.
>
>

Re: Wellknown-Singleton object is being created 2 times by polism

polism
Tue Nov 29 19:32:24 CST 2005

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