Click here to Skip to main content
15,924,507 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Please help me out for this as soon as possible..Thanks in advance

What I have tried:

i know we can't have a GUI for windows service.
and so I have created my GUI based windows application.
then i have tried to call this exe file of the windows app in my windows service.
when i start my service after deploying i was unable to see the GUI of window app running. but now i have set the properties of service in administrative tools -> services -> right click -> goto properties -> under Log On tab check allow to interact with desktop.
but my problem is not solved yet . I cant see the GUI of windows app running through service as I am unable to call exe file of my application in service.


I got this above solution from Code project only but i am getting the same problem yet.Please give me suggestion.
Posted
Comments
Richard Deeming 12-Feb-16 12:49pm    
Looking at the history, this copy of the question was posted five minutes before that one. :)
Philippe Mori 12-Feb-16 12:28pm    
If you know you cannot have a GUI from a Windows Service then why you ask the question?

OK, I'm not 100% on the details here but I don't think this will work. I'm sure someone will point out my error if this is incorrect, the people here are helpful like that.

Services run under a different session - a session being a thing which can have one or more desktops - but not the desktop you interact with. Services should not interact with the desktop anyway - this is a legacy feature, and if you turn this on, it will be interacting with a desktop which isn't the one on your screen.

(When you lock your computer, that desktop vanishes and a new one appears with just a log in box in it etc. etc.)

What I am sure about is that you should not be doing this. Services are long running processes that work silently in the background and should not be interfering with the goings on of the user. If you want to talk to it, you should launch the GUI application yourself and it should converse with the services using sockets/pipes/whatever.
 
Share this answer
 
This is the better approach which is often used:
  • Create a "normal" Windows Service. In this service, create a communication channel for the local application, which can be based on named pipes, sockets (TcpListener), WFP self-hosted service with a local communication channel, something like that. It could be half-duplex or full-duplex.

    If both the service application and your control Windows application (see next item) are .NET applications, WCF is probably the most convenient and flexible solution.
  • Create a "normal" Windows application. One form very suitable for working with a Window Service could be the application sitting in the system tray, such as the application based on NotifyIcon: https://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon%28v=vs.110%29.aspx[^].
  • Register/install your Windows application to start on system start.
  • On start, your Windows application tries to connect to the service. When connection is done, it can control the service and get notifications from the service.


I understand that each of the above items could be a matter of a separate question and answer, but it makes little sense to describe it all at once. Try to work on each aspect yourself and ask other questions if you cannot achieve some of those parts.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900