[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework

How to connect to a service

Patrick Sona

7/11/2008 1:58:00 PM

Hi all!
I have written a small little windows-service. I can start and stop this
service in the service-snapin. So far all pretty nice!
But i need to controll this service. It is possible to send this service
an object (such as a string) an receive object (also a string, or
another object)?

The only what I have found yet is the ServiceController. With this class
I can connect to service an can get some information about it. i can
also shut down or start a service or can send a custom signal to it, but
I couldn't sent an object to the service.

Is there a way to do this?

Thanks for replies!

Greetings
Pat
3 Answers

Eugene Mayevski

7/11/2008 2:10:00 PM

0

Hello!
You wrote on Fri, 11 Jul 2008 15:58:07 +0200:

PS> The only what I have found yet is the ServiceController. With this
PS> class I can connect to service an can get some information about it. i
PS> can also shut down or start a service or can send a custom signal to
PS> it, but I couldn't sent an object to the service.
PS> Is there a way to do this?

There exists a number of ways to communicate between the processes:
* sockets
* named pipes
* memory-mapped files (shared memory)
* mailslots
* etc.

You can check MsgConnect ( http://www.eldos.com/m... ) it was
designed for the tasks similar to yours and it lets you build flexible
communication via MMF or sockets.

With best regards,
Eugene Mayevski
http://mayevski.blo...

Jeroen Mostert

7/11/2008 2:25:00 PM

0

Patrick Sona wrote:
> I have written a small little windows-service. I can start and stop this
> service in the service-snapin. So far all pretty nice!
> But i need to controll this service. It is possible to send this service
> an object (such as a string) an receive object (also a string, or
> another object)?
>
You can use .NET remoting or WCF for this purpose, if your service and the
applications that control it are managed. This is by far the easiest
approach. Alternate approaches are one of the many unmanaged communication
mechanisms, mentioned by Eugene Mayevski.

Be careful in designing the interface to your service. Services usually run
at elevated privileges and pose a security risk if unprivileged clients can
control them in unexpected ways.

--
J.

Patrick Sona

7/14/2008 7:52:00 AM

0

Jeroen Mostert schrieb:
> Patrick Sona wrote:
>> I have written a small little windows-service. I can start and stop
>> this service in the service-snapin. So far all pretty nice!
>> But i need to controll this service. It is possible to send this
>> service an object (such as a string) an receive object (also a string,
>> or another object)?
>>
> You can use .NET remoting or WCF for this purpose, if your service and
> the applications that control it are managed. This is by far the easiest
> approach. Alternate approaches are one of the many unmanaged
> communication mechanisms, mentioned by Eugene Mayevski.
>
> Be careful in designing the interface to your service. Services usually
> run at elevated privileges and pose a security risk if unprivileged
> clients can control them in unexpected ways.
>

Thanx for the both responses!

So I will try some of the IPC-methods. I think named-pipes do it for me!

Greetings
Pat