views:

28

answers:

2

hi,

i'm trying to create a windows service with C# in .net that runs before the user is logged on... then when a user is logged on a symbol should appear in the system tray (next to the clock) to show the user that the service is running.. by double clicking that symbol a configuration utility (written in wpf) should be shown to the user, so he can configure the service, read data from it and so on ..

is there a possibility to do this within one application?

thanks in advance for any help!!!

+2  A: 

Within one application, no. Services run in session 0, please see here:

http://www.microsoft.com/whdc/system/sysinternals/session0changes.mspx

Your best bet is to used Named Pipes, see here:

http://www.switchonthecode.com/tutorials/dotnet-35-adds-named-pipes-support

....or a memory mapped file, see here:

http://msdn.microsoft.com/en-us/library/dd997372.aspx

Within the scope of more-.NETty, you could also use Remoting. You'll need to come up with some interface or protocol to facilitate communication between the service and the management utility. Managing the process start/stop would be easier and you could use the ServiceController class (MSDN ref).

Hope that helps (and itsn't too discouraging)!

Kieren Johnstone
+2  A: 

Hi!

No, you can't do this with one application as services run with a different user in a different session. You need to create two applications and implement some communication between both.

I would not recommend using named pipes directly (like Kieren Johnstone suggested), but to have a look at WCF which was designed for interprocess communication and nicely abstracts implementation details of the communication technology away from you. Here is a link that can propably help you with WCF: http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication.

Best Regards,
Oliver Hanappi

Oliver Hanappi