Can you display a message box (or any form of notification) from a windows service? Can't get it to work. I used:
global::System.Windows.Forms.MessageBox.Show("A fatal error occurred. " +
ServiceName + " is now terminating.");
but it didn't work and just produced an error.
To display a message box, call the static method MessageBox. Show. The title, message, buttons, and icons displayed in the message box are determined by parameters that you pass to this method.
a title that can represent the source of the message. an icon for each message type to determine how critical a message box is. a brief text message. some command buttons that can represent a user decision.
No, you cannot show a message box from a service. If you want to report errors, the standard way to do this is with the event log.
For more "advanced" kinds of UI (not just error reporting), the way this is typically done is via a regular windows application that you put in the user's Startup folder (or the Run key in the registry) and that talks to the service via some kind of IPC mechanism (.NET remoting, WCF, regular sockets, named pipes, etc).
You can display a message from a service with "WTSSendMessage(...)" function (which is available since Windows Vista
and Windows Server 2008
), here is a good article:
http://msdn.microsoft.com/en-us/library/ms683502(VS.85).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With