Search code examples
windows-servicesmessagebox

Show a message box from a Windows Service


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.


Solution

  • 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).