all groups > dotnet remoting > july 2005 >
You're in the

dotnet remoting

group:

More singleton objects in the same application


More singleton objects in the same application Cinnio
7/29/2005 1:38:08 AM
dotnet remoting:
Hi all

I have a windows application exposing via remoting three singleton
objects, let' call them "SA", "SB" and "SMain" .

"SA" and "SB" are instantiated by remote client applications (which
reside on the same machine).

"SMain" object is instantiated by "SA" and "SB".

Because of this, I have to configure "SA" and "SB" to use remoting for
instantiating "SMain", the reason of this is because I want it to be
singleton (a single instance of it).

Since in the same application "Smain" is already configured as a
WellKnownServiceType, so I can't have it also configured as a
WellKnownClientType.

If i try doing this I get the Exception:
"Remoting configuration failed with the exception
System.Runtime.Remoting.RemotingException"
"Attempt to redirect activation for type"
"This is not allowed since either a well-known service type has already
been registered with that type or that type has been registered has a
activated service type"

The obvious solution is to put "Smain" in another application.

I wanted to have the three objects in the same application: is there a
way to obtain this?

Thanks in advance
Re: More singleton objects in the same application Roy Chastain
7/29/2005 1:32:13 PM
As I understand it, SA and SB are local singleton objects that are being instantiated via remoting from remote clients.
SMain is a local singleton that you intend to instantiate from SA or SB which are resident in the same Application Domain.

If you are only using remoting to force SMain to be a singleton, then I would suggest you make it a normal object (not remoted)
and use a factory pattern to enforce the single instantiation.


[quoted text, click to view]

-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
Re: More singleton objects in the same application Cinnio
7/31/2005 1:13:18 AM
Thanks Roy,
you understood it right.

Anyway, I was looking for a more "automated" solution either than
writing custom logic (such as a factory pattern).
I wanted to continue using remoting infrastructure.

I think I should create an appdomain for my "SMain" object.
I am looking for a code sample of this, i.e more remoting server on the
same process calling each other.
Re: More singleton objects in the same application Cinnio
8/3/2005 4:35:58 PM
i've soloved it out.

I posted a solution in my blog:

http://cinnio.blogspot.com/

comments are welcome ! :)
AddThis Social Bookmark Button