I'm developing a windows service in C# .Net and i'm having some dificulty to execute and test my service. I'm using a timer component to run it from time to time and execute my methods. I have to intialize the service all the time to run it. Anyone know a more practical way to test a service?
Start Visual Studio with administrative credentials so you can attach to system processes. (Optional) On the Visual Studio menu bar, choose Tools, Options. In the Options dialog box, choose Debugging, Symbols, select the Microsoft Symbol Servers check box, and then choose the OK button.
Start the service (you can use net start , or start it in the Services window). You should see a dialog box like the following: Select Yes, debug <service name>. In the Just-In-Time Debugger window, select the version of Visual Studio you want to use for debugging.
A Windows service is a long-running application that can be started automatically when your system is started. You can pause your service and resume or even restart it if need be. Once you have created a Windows service, you can install it in your system using the InstallUtil.exe command line utility.
This often boils down to the question what you want to test. Do you want to test the service, or the functionality that it performs? Personally I would...
...and then keep the amount of code in the service itself to the bare minimum needed to trigger the functionality in the class library.
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