Debug windows service on remote server
Run ServicesToRun which isnt much use to me. The service has a timer which sets off every 30 seconds and will run the code in the timer event. My question is Do I need to have some debug specific code already in my codebase so that when a debugger attaches it will take me to a place in the code from where i can step through the code? There are several ways to debug your developed remote application or windows service.
If you were in your machine local that would be simple to debug. But as you are in different machine it depends how your both Machines are connected. You can use Remote Debugging Monitor that visual studio use for connecting to remote device and debugging.
There's another tool which lets you debug remote application's after a proper setup. But it has some limitations or conditions that you must abide by. It has been clearly quoted there about the prerequisites for using this tool. But still I'm rephrasing those again for quick reviewers. Ensure that you are running the same code on the target machine as you have open in Visual Studio.
It has to be the same assembly and version else the debugger will not hit your breakpoints. Ensure you have your breakpoints setup where you want the debugger to break execution. Then attach to the target machine process and wait for the timer to kick in and run the process where you breakpoint is set. In the Application tab of the project's properties, set the Output type to Console Application. To run the program as a Windows Service again, install it and start it as usual for a Windows Service.
It's not necessary to reverse these changes. In some cases, such as when you want to debug an issue that occurs only on system startup, you have to use the Windows debugger. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Is this page helpful? Please rate your experience Yes No. Any additional feedback? Warning This documentation isn't for the latest version of Windows Service. Create a Windows Service using BackgroundService.
Caution You should not attach to a process unless you know what the process is and understand the consequences of attaching to and possibly killing that process. Note Debugging the OnStart method can be difficult because the Services Control Manager imposes a second limit on all attempts to start a service. There are plenty of ways. I suggest you go with the simplest method first. Use multiple try catches as per the need of your code and in the catch block mention a meaningful message to know where exactly the exception was thrown and for what reason.
Based on BhushanMuttha clue. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 1 month ago. You can debug a Visual Studio application that has been deployed on a different computer.
To do so, you use the Visual Studio remote debugger. If you just want to download and install the remote debugger and don't need any additional instructions for your scenario, follow the steps in this article. On the remote device or server that you want to debug on, rather than the Visual Studio machine, download and install the correct version of the remote tools from the links in the following table. You can run the remote debugger by copying msvsmon.
However, the Remote Debugger Configuration Wizard rdbgwiz. You may need to use the wizard for configuration if you want to run the remote debugger as a service. For more information, see Optional Configure the remote debugger as a service. The remote computer and the Visual Studio computer must be connected over a network, workgroup, or homegroup, or else connected directly through an Ethernet cable.
Debugging between two computers connected through a proxy is not supported. Debugging over a high latency or low bandwidth connection, such as dialup Internet, or over the Internet across countries is not recommended and may fail or be unacceptably slow. You can find the remote debugger msvsmon. For some scenarios, the easiest way to set up remote debugging is to run the remote debugger msvsmon. On the remote computer, run msvsmon.
Follow the setup instructions. For command line installation and command line reference, see the Help page for msvsmon. On the remote computer, find and start the Remote Debugger from the Start menu. If you don't have administrative permissions on the remote computer, right-click the Remote Debugger app and select Run as administrator.
Otherwise, just start it normally. If you are planning to attach to a process which is running as an administrator, or is running under a different user account such as IIS , right-click the Remote Debugger app and select Run as administrator.
For more information, see Run the remote debugger as an administrator.
0コメント