Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In windows service after starting my service i got message. here messagebox.show method not working. is there any other solution?
Posted

You can not use System.Windows.Forms objects in windows service, a services can not throw messages as message box...log if want to log any information in the event log.
 
Share this answer
 
Comments
SAISAGAR nalla 1-Oct-11 0:27am    
how can i set logs
Pradeep Shukla 1-Oct-11 1:00am    
Go through this: http://support.microsoft.com/kb/815314
SAISAGAR nalla 1-Oct-11 3:08am    
i known but how to get message here. i am not getting. i am using only windows services not a windows application
Pradeep Shukla 1-Oct-11 13:20pm    
import the namespace: System.Diagnostics
and use following code where you are showing messagebox:

EventLog ev = new EventLog("System", System.Environment.MachineName, "MySystemSource");
ev.WriteEntry("Warning is written to system Log", EventLogEntryType.Warning, 10001);
ev.Close();
SAISAGAR nalla 3-Oct-11 1:19am    
hai.. here i am getting message at in my service but not like a message box. in my server Eventslog-->system--> in that message displayed. i want po up message
Windows services are not meant to interact with the user at least not in the way you're trying.
If you want pop-up messages - I assume you're working on the same machine as your service is running on - then just write a small tray application which receives your messages and displays them to you.

Best regards
 
Share this answer
 
Write your message in MessageBox.show method.
After your service started , Goto services--> select ur service--> right click Properties-->Click on log on tab--> chesk allow intractive with desktop-->Click Apply Button--> After restart ur service.. u get what ever u wrote in ur messageBox.show();




plz accept and give rating also
 
Share this answer
 
Comments
CodingLover 3-Oct-11 1:24am    
It cannot be done in programatically.
Bala Selvanayagam 3-Oct-11 3:39am    
I think SAISAGAR is right,

You can add the System.Windows.forms namesspace to your service and call the messagebox.show(); method which in turn can popup on the same machine where the service is running(you have to Goto services--> select ur service--> right click Properties-->Click on log on tab--> chesk allow intractive with desktop-->Click Apply Button--> After restart ur service.)


If you wish the message to be popped up in a different machine than the one where the service is installed then you can use "NET SEND" ?
Arun Kumar K S 3-Oct-11 4:53am    
This will create one interactive desktop for windows service but not with user desktop that the user interacts

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