I am writing a windows service that will be doing a lot of network communication, and I need a way to notify a user (if logged on) of any exceptions/errors. I know it is bad practice to allow a service to interact with the desktop, so is there an alternative way to notify a user that an error has occurred? I am aware of event logging, but I would also like to be able to show a notification bubble from the system tray or something that catches the user's attention.
If the main thing you want is for the Services window to report that there was an error, from what I've tried (.NET3.5 on Windows 7), the only way to do this is by setting the ExitCode. I recommend setting it to 13816, since this results in the message, "An unknown error has occurred." See the windows error codes.
Microsoft can use the error reporting feature to provide customers with troubleshooting information, solutions, or updates for their specific problems. Developers can use this infrastructure to receive information that can be used to improve their applications. Users can enable error reporting through the Windows user interface.
Monitoring Windows Services is critical to making sure that they are working correctly and performing well. Retrace is an excellent solution for monitoring the performance of your Windows Services. Retrace works with all ASP.NET, .NET Core, and .NET applications. Retrace also works for Azure WebJobs and Azure Functions.
In Windows, open the Services desktop app. Press Windows+R to open the Run box, enter services.msc, and then press Enter or select OK. You should see your service listed in Services , displayed alphabetically by the display name that you set for it.
Please consider using Event Log and a separate application just for monitoring. You can also consider using emails or MSMQ.
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