Groups | Blog | Home
all groups > dotnet remoting > may 2006 >

dotnet remoting : Raising Events from a Windows Service


Dan Alexander
5/19/2006 3:46:01 AM
Hi,

I've got a problem with Remoting and I was wondering if you kind folks could
shed some light on it. Here's the situation:-

I have a windows service that gathers information from a source once a
minute; After it has gathered the information I need it to inform any client
applications that happen to be listening that the information has been
fetched.

My solution was to create a remotable object that inherits from
MarshallByRefObject and has a delegate and an event etc. The service then
hosts this object. It then creates an instance using Activator.GetObject so
that it can raise events. I tried just creating an instance of the object but
no clients were recieving the events! In essence the windows service hosts
the object and then creates a client for itself.

This all works fine and I can connect a client to it and the client will
recieve events.

The problem is that when I shut down the client (a simple windows app) the
windows service keeps throwing socket errors
(System.Net.Sockets.SocketException) saying that the host actively refused
connection. Now, I'm guessing its because the instance within the service is
dead because the client application has killed it off somehow.

Basically what I need to know is how can I get a Windows Service to inform
clients that things are happening?

If you want a copy of my code then let me know and I'll zip it up and send
it on. Thanks for any replies,

William Sullivan
6/1/2006 6:33:01 AM
If I understand you correctly, you are still firing off events registered by
clients after the client has exited? Do your clients unregister from the
events prior to shutting down? Have them do this prior to exiting and see if
that makes a difference.

[quoted text, click to view]
Dan Alexander
6/1/2006 8:29:01 AM
I've managed to figure it out and yes, it was to do with registering and
unregistering handlers (good ole AddHandler and RemoveHandler).

[quoted text, click to view]
Marc
6/27/2006 2:20:50 PM
Hey Dan,

I'm trying to do something similiar but have hit a roadblock. Can you email me the source code.

Marc
6/28/2006 8:22:03 AM
AddThis Social Bookmark Button