Debugging a Windows service - visual-studio

I learned that for Windows Service Debugging in Visual Studio 2015 IDE,
launch the service from IDE using the ā€œ-cā€ command-line switch. This enables the service to run as a console application.
Why do we need to enable the service to run as a console application, in order to debug the service?
Does running as a console application here mean running as a foreground process?
Does running a service here mean running as a background daemon?
How do we debug a service, if running it normally instead of running as a console application?
Is the switch "-c" a switch of Visual Studio debugger, or of something else?
Thanks

This blog also shared us the reason why we convert a Service to Console Application for Debugging like "debug more easier" or others:
https://social.technet.microsoft.com/wiki/contents/articles/30957.c-windows-service-in-console-mode-for-debug-and-admin.aspx.
I think the command line switch would be similar to the UT project property settings.
To debug the windows Server without using the console app type, you could use the attach to process or customer code or unit tests:
https://msdn.microsoft.com/en-us/library/7a50syb3(v=vs.110).aspx
Easier way to debug a Windows service

Related

Why I can not attach the debugger to App Services running in this subscription?

I'm using Visual Studio 2019. I can attach the debugger to services running in my own subscription.
When I try to attach to services running in another sub from cloud explorer, I get various errors and the attachment never succeeds. The most common is:
Unable to find a process called w3wp with arguments {app service name}. The process may still be starting, please try again.
When trying to attach under the Debug -> Attach to Process dialog, I get the following error:
Unable to connect to {path}. The connection with remote endpoint was
terminated.
I have owner role on the subscription, on the app service and on the app service plan.
Please validate if you have enable debugging from azure platform side. Screen shot od the same from portal looks like:
Also please confirm if you have deploy application from VS.
Visual Studio remote debugging on azure app services used 4020, 4022, 4024 ports for debugging.
https://learn.microsoft.com/en-us/azure/app-service/networking-features#app-service-ports

Problems debugging web role remote on Microsoft Azure

I am trying to debug a webservice remote on Microsoft Azure. The service is running in a web role.
I have configured remote debugging in the publish settings an can attach the debugger to the web role. Also, when I have selected the correct process, the debug symbols are loaded correctly and breakpoint's tool tips say that the breakpoint is hosted in "WallSHost.exe" which is the remote process.
What I would like to do, is to run a local client software which I am developing and step into the server code from there. When I step into the according service client call (F11), I get the above error message, saying (for the sake of Google in plain text here):
Unable to automatically step into server. Connecting to the server
machine 'xyz.cloudapp.net' failed. The Microsoft Visual Studio Remote
Debugging Monitor (MSVSMON.EXE) does not appear to be running on the
remote computer. This may be because a firewall is preventing
communication to the remote computer.
I have tried to disable the firewall on my (the client) machine with no effect. Has anybody seen that before or can tell me how fix this problem?
A quick checklist
deployed cloud service is a debug build
a debug build is selected from Build Configuration list (in publish wizard)
'Enable Remote Debugger For All Roles' is checked
no changes to code since deployment

remote debugging in visual studio cannot connect

Hello i have a problem with remote debugging in Visual Studio (v12)
I Created windows azure account i published application to the cloud.
Then i connected to this account through remote desktop. Address of remote computer is f.e Iron.app.net
Then i downloaded there and run remote debugger. I started msvsmon.exe and it created server named:
RD0015555E2:555
And now i would like to remote debugging in my host.
i know i must attach to process. And i do it.
From Visual Studio: Debug->attach to process->Qualifier:RD0015555E2 and it cannot resolve host name.
i also tried Iron.app.net but then it shows error that it seems that msvsmon is not installed.
I dont know what should i type into Qualifier (as remote machine)?
Remote debugging is tricky to configure Windows Azure Cloud Services. Other options that you have are:
Intellitrace (in case you've got Visual Studio Ultimate)
Intensive (verbose) pro-active code instrumentation (logging) from the beginning.
Profiling Cloud Service
Chose either, and watch your logs/traces.
Or deep dive into Remote Debugging Cloud Services. I would, however use Remote Debugging as a final option, when everything else does not work and does not help me. Typically most of the issues that would pop in the cloud will also pop in when debugging locally. And if role is just recycling, you will not be able to attach debugger at all.

How to attach to and debug an ASP.NET MVC application running in Windows Azure Emulator?

I am writing an MVC 3 application to run in Windows Azure. On my local machine I use the Windows Azure emulator.
If I press F5 in my solution ("Start debugging") I'm able to put breakpoints and step through the code of my application.
Do you know if it's possible to attach to the application if it's already running (if it's been started with CTRL + F5, "Start without debugging")? If yes, how?
In ASP.NET running in IIS I just have to attach to the w3wp.exe process. How to do the same for the Windows Azure emulator?
If you are running the application in IIS (have a Sites section in your config file) then you will do it the same way with the emulator. Azure creates an Application Pool for the deployment so you will just need to attach to that w3wp.exe process.

debugging windows service: breakpoint will not currently be hit

I have attached the process for my windows service which is running/started on my machine. In vs.net 2010 I have a few breakbpoints set in my service, but each of them says?:
'break point will not currently be hit'
what is the easiest way to get the debugging for windows services happening?
This is the correct way to debug the windows service but you should be sure that the files of the windows service are updated. I mean that whenever you build the windows service project you should stop the service, replace the windows service exe and the related dlls and then restart the windows service.

Resources