Get data from Windows Service

S

Steve Amey

Hi all

Is it possible to retrieve data from a Windows Service? Let's say I have a
service that contains code in the OnStart method that creates a DataSet,
from a client application I'm using a ServiceController to check that the
Service on the specified machine is running, can I get the DataSet that is
held within the Service? Is it possible to create Properties or have a
function that returns the DataSet?

Kind Regards,
Steve
 
J

Jay B. Harlow [MVP - Outlook]

Steve,
The "easiest" way would be for the Windows Service to be a .NET Remoting
host.

Then you client can use .NET Remoting to connect to the Service & retrieve
any information it wants.

Matthew MacDonald's book "Microsoft Visual Basic .NET Programmer's Cookbook"
from MS Press discusses in more detail various methods of interacting with a
Windows Service.

Hope this helps
Jay
 
S

Steve Amey

Hi Jay

Thanks for your reply.

I want to keep away from Remoting if possible. Do you have any links to
resources that describe how to share data across multiple instances of an
application? They do not have to share data across machine boundaries, so
remoting is not necessarily needed if there are other viable solutions.

What I'm looking for is to store a DataSet in 1 place and have all the
applications running (they will be the same application, just many
instances) accessing that data. I was hoping I could extract a DataSet from
a Windows Service, but I guess that's not possible if you don't want to use
remoting.

The data shared should only be in memory, not persisted to any files or
databases.

Thanks for any help,
Steve.
 
J

Jay B. Harlow [MVP - Outlook]

Steve,
..NET Remoting is used to share data across process boundaries on the same
machine, just as easily as it can across machines.

The only caveat is, I understand that currently you need to use TCP/IP on
the same machine, where as VS.NET 2005 (aka Whidbey, due out later in 2005)
will have an IpcChannel that will allow you to use .NET Remoting on a single
machine without TCP/IP: http://msdn2.microsoft.com/library/tz3ew9z6.aspx

I believe you could implement an IpcChannel for VS.NET 2002 or 2003, however
I don't know of any samples.

You might try the microsoft.public.dotnet.framework.remoting newsgroup.


Alternatively you could try to use memory mapped files or even normal files.
The Service could save the data, your control program could read the data.

Hope this helps
Jay
 

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