Click here to Skip to main content
15,907,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please Help me out. I am new in .NET. Anybody know how to open a winform using windows service.Pleas help me. Thanks in advance.
Posted

You cannot. You can however, have a form that can interact with services that are running on the system.
 
Share this answer
 
Comments
Kim Togo 27-May-11 7:12am    
Good answer, 5.
Abhinav S 27-May-11 7:15am    
Thank you.
Sergey Alexandrovich Kryukov 27-May-11 14:38pm    
Good, a 5. Again, confusion about a concept of the Service.
--SA
Sergey Alexandrovich Kryukov 27-May-11 14:46pm    
I added my answer giving a credit to your answer -- just a couple if ideas, please see.
--SA
Abhinav S 27-May-11 14:47pm    
Thank you SA.
A service is a long running executable that does not require user intervention. See here for more information[^].
As such it is not possible to open a Form from a service. And even if it is possible it is not recommended. Perhaps you want to make an application that communicates with a service? If that is the case Windows Communication Foundation[^] may be what you need.
Or maybe you need to rethink your strategy and ask yourself if you REALLY need a service :)
 
Share this answer
 
Comments
Kim Togo 27-May-11 7:12am    
Good explanation! My 5.
Sander Rossel 27-May-11 7:33am    
Thank you :)
Sergey Alexandrovich Kryukov 27-May-11 14:46pm    
Naerling,
I added my answer giving a credit to your answer -- just a couple if ideas, please see.
--SA
RaviRanjanKr 28-May-11 0:56am    
Good Answer, My 5 :)
Be logical: a Windows Service keeps running even if nobody logged on. Where do you want to show a form? You are probably confused about the very concept of the service. However, there is nothing wrong in having a separate Windowed process which can interact with the Service. See the solutions by Abhinav and Naerling.

Moreover, this is a very typical approach used, in particular, for Service control.

By the way, the most adequate form of such application is the System Tray application based on the class System.Windows.Forms.NotifyIcon. See http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx[^].

—SA
 
Share this answer
 
v3
Comments
Abhinav S 27-May-11 14:47pm    
Good point. 5.
Sergey Alexandrovich Kryukov 27-May-11 14:48pm    
Thank you, Abhinav. I cannot believe you response could be so fast. :-)
--SA
Abhinav S 28-May-11 0:39am    
You are welcome. :)
Sander Rossel 27-May-11 14:53pm    
You pointed to the solutions of Abhinav and KIM! This is the second time today I had to edit my name in your solution. Next time I am giving you a 1 vote for sure :p
Your solution does make a good point though. So my 5 for suggesting the NotifyIcon.
Sergey Alexandrovich Kryukov 27-May-11 23:43pm    
Hm. I'm getting unlucky with you, don't know why. Sorry.
Thanks for the fix.
--SA

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