Communicating with a Windows Service

G

Guest

I have written an application that runs as a Windows Service. I have also written a small windows forms application to send the service some custom startup parameters. The application is also able to connect to instances of the service on the local machine, as well as remote servers.

I am having trouble deciding the best way to give the client app the ability to retrieve what the current parameters are for a running instance of the service. Actually I am having trouble even deciding where to start as there seem to be a number of possible ways.

Any thoughts? Thanks for any help!
 
G

Guest

Woah! Sorry for kind of doing a double post. I just noticed the "Network Communications" post from earlier.
 
G

Guest

Heh, yeah I'm Devin and Kettch, for a second there I forgot which username I use on this forum.
 
G

Guest

I'm mulling over a similar design problem where I need to communicate between ans service and WinForm application. In my scenario I want to perform configuration updates plus I would like some of the ongoing status information of the service to be displayed in the separate application (perhaps to log window) and also allow for some commands to be sent from the separate application to the service. I'm seen ideas here and there about using remoting, XML disk files, message queing, TCP packets, UDP packets, etc. Normally the the general idea would be to use of of these mechanisms to pass back and forth objects (serialized as XML) containing (in my case) log or command data. Unfortunately, almost every article I've seen focuses on the mechanics of building a Win Service with no comments about good practices for communicating with 'em.

--Danny Lee
 
G

Guest

I have done this using remoting and it works perfectly. My service is running on a server and the user interface can be run on any client machine. For the client to receive notifications from the service, I use the Observer Design Pattern from "Gang of Four" to avoid any remoting problems with the usual .net events.

Regards, Jakob.
 
A

allonb

Hi,

Can you please give some more details about how you were able to host a remoting server in your service and have that server control your service.

I have managed to find many samples on how to host remoting objects in a Windows service but I am unsure how you use one of those objects to control the service.

Thanks
 
S

Sunny

Hi,

if in your service you create a static remoting object, and after that
you do not use WellKnownServiceType, but RemotingServices.Marshal of
that object, it will be exposed as a Singleton, and in your service you
will still have a reference to it. So, when you create that object, you
can pass to it a reference of the your main object, which have to be
controlled. And upon a client request, it will do something on the
service.

Sunny
 

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