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

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.

Related

Process.Start("chrome.exe","url") not working on Dotnet worker service after service hosted on windows

I have Dotnet core Worker Service application in the version 6.0.
I am trying to open a website using System.Diagnostics.Process. it is working fine when I am in debugging mode on visual studio, when I hosted service using below Command on windows.
SC create serviceName binpath="abc.exe"
Services working fine after hosting but Process.Start("","") not throwing any exception also not open any browser. there is no log on windows & event viewer.
any help on this will be appreciate.
Enable allow service to interact with desktop.
using processinfo to set UseShellExecute.

Debugging a Windows service

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

Stop ASP.Net Development Server spinning up when using Azure Emulator

I am using The Azure Emulator for test deployment of an ASP.NET Web API application. When I run this I notice that the asp.net dev emulator also runs. As this does not seem to be needed, is there a way to stop it from spinning up?
There are couple of things to understand with Windows Azure ASP.NET Web role application:
When you have your Web Role set as "Startup Application" or you run ASP.NET web Role application only, you you will see the ASP.NET site runs at http:\localhost:XX this is because you are running your web application directly in IIS without any relationship with Azure Compute Emulator.
When you have your Windows Azure project set as "Startup Application" or you launch your Windows Azure application directly, in that case your ASP.NET web application will run within Windows Azure Compute Emulator. In this scenario the Compute Emulator will start if not running and if running then the ASP.NET web application will still run with IIS however due to virtual load balancer scenario you will see the ASP.NET web application is running at http://127.0.0.x:XX.
So depend on how you launch your project within your solution you will see different execution. When compute Emulator is running you can open its UI to understand how your different instances are running.
Finally based on your above requirement it seems you just want to test your application in IIS only so if you just set your ASP.NET web role to "startup project" you will not see compute emulator activity.

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.

VS2010 - Debugging a silverlight 4 OOB with breakpoints in the WCF services

I created a silverlight 4 app , and chose to host it in a ASP.NET Web Application.
I added a Silverlight-enabled WCF Service to the Web Application Project.
The Web Application project is now set to be the startup project.
This way every thing works fine and I can stop at breakpoints in the WCF services in the Web app project, and also stop at breakpoints in the silvelight project.
In the silverlight project properties, I changed it to be an OOB. This causes the startup project to automatically jump to the silverlight project. OK, so now when I debug the silverlight app it's opened OOB, but now I cant put breakpoints in the WCF services in the Web app project (Although the silverlight client can communicate with the web app project) . So I changed the startup project to the Web app again. But now the silverlight app doesn't start as OOB.
How can i debug in the WCF services, and run it OOB at the same time ?
(My app is designed as an OOB, so it's important for me to develop it that way).
First, You have to set a breakpoint on your client side, right before you call a service operation.
Second, set another breakpoint inside the service method on the server side.
Now, when you start debugging and hit the first breakpoint, attach the dev server process to the debugger by doing the following steps:
click Debug - > Attach to process
select the Webdev process and click attach.
now when you continue to debug, you will be able to debug your service as well :)
When you start debugging, you should go into Visual Studio and manually attach the debugger to the development web server (Debug->Attach to Process...). This step is not done automatically when debugging OOB.

Resources