[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Accessing a singleton from a server instead of a client

jeff

6/9/2004 8:24:00 PM

I have a windows service that has a singleton remotable object. I need
to call the singleton's startup method from the service's OnStart
method.

Problem is, if I try to do that, I can't. Since I'm already using tcp
to host the service, if I do something like this

Dim objRemote As New HashObject.HashObject()
objRemote = Activator.GetObject(objRemote.GetType,
"tcp://diadem:7777/ServerHello")

It crashes because the service is already using the tcp channel.
Clients can do this all day, but I need the service itself to access
the singleton.

How do I do this?
1 Answer

Sunny

6/10/2004 3:14:00 PM

0

Hi,


do not expose the object with RegisterWellKnown.... or with config file.

Make something like this:

MyRemClass remobj = new MyRemClass();
RemotingServices.Marshal(remobj, "myservice", typeof(..));

Now your object is exposed as singleton to the clients, and you still
have access to it from your code.

Sunny


In article <56ea494d.0406091224.3b138a2@posting.google.com>,
jeff@wspi.com says...
> I have a windows service that has a singleton remotable object. I need
> to call the singleton''s startup method from the service''s OnStart
> method.
>
> Problem is, if I try to do that, I can''t. Since I''m already using tcp
> to host the service, if I do something like this
>
> Dim objRemote As New HashObject.HashObject()
> objRemote = Activator.GetObject(objRemote.GetType,
> "tcp://diadem:7777/ServerHello")
>
> It crashes because the service is already using the tcp channel.
> Clients can do this all day, but I need the service itself to access
> the singleton.
>
> How do I do this?
>