4

I have a desktop application in C# and i want to make that a window service. Is it possible to make that application as a windows service? Basically i want an app that shows gui when needed and upone minimizing it goes to system try, and it should also appear in services... For application just take an example that my application have a timer and multiline text field and its also interacting with database and its showing timely status from database so when i need to see it i can start GUI from system try?

Any kind of help would be highly appriciated. Thanks!

2
  • I've got an app I'd like to do this to, but it's complicated enough that I haven't gotten to it yet. It's not trivial, as the answers below indicate. Commented Feb 25, 2013 at 15:15
  • I also have those issues with legacy projects, for the more complicated ones, for now, I'm using Service O-Matic, it isn't free but it does the job. There are also some free products like restartOnCrash, which didn't do the job for me Commented Feb 25, 2013 at 15:18

2 Answers 2

3

You will need to separate your applications. Windows Service and desktop. You will need to build API hooks into your Windows Service to allow communication from your desktop application and the service. I would recommend WCF for this.

In a nutshell, a Windows Service should not interact with the desktop. It will run in a separate session than the session you are logged into, even if you are logged in as the same account the service is running under.

Sign up to request clarification or add additional context in comments.

2 Comments

Right! Find additional details on GUI services in the Windows Services FAQ
Interesting, I haven't dealt with the Interactive Services Detection before. I still wouldn't use it because it is just another point of confusion to the user. I will revise my statement of can not to should not... since technically it can, but just because you can, doesn't mean you should.
1

It is not possible to show GUI in a windows service. What you can do is:

a. Seperate client logic from server logic, the windows service will perform the server side operations and will expose a WCF API to the client , which will handle the GUI related issues.

b. Use an external tool like Service-O-Matic to control your winforms application as if it was a windows service. see:

http://www.kwakkelflap.com/service.html

1 Comment

Also note that UI timers will not work on the windows service, and any attempt to show GUI in the service will result in an exception.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.