Debugging ASP.NET website from Visual Studio causes restart of the website - visual-studio

Somehow, since some time I'm experiencing problems with debugging my ASP.NET website.
Every time I try to debug the website ASP.NET shuts down (global.asax_Application_End is called).
I believe this is triggered because the site is built by Visual Studio. However, manually (re)build the site and then start debugging also restarts the site. Even debugging and ending the debugging session, clicking a couple of buttons on the site to get to the desired state, and start a debugging session again still triggers a build action, which causes the site to restart.
Since restarting resets HttpRuntime.Cache booting the site takes a long time, and sometimes I want to debug some situation that involves caching.
Now there is a setting on the website's property pages:
Start Action (F5):
Before running startup page:
No Build / Build Page / Build Web Site.
I've set it to No Build, restarted Visual Studio, but still it triggers the build action every time I hit F5 or the Start debugging button...
Anyone any ideas as to how to resolve this??
Thanks,
Jaap

We've solved this by converting our project to a Web Application instead of a Web Site. This had some impact on our architecture since we had some classes in app_code which we needed to use reflection on during site startup.
It turns out that the Web application in combination with "Use Custom Web Server" fixed out issue!

Related

Visual Studio 2017 attaches to the wrong w3wp process

Started working this morning and quickly discovered Visual Studio 2017 debugging of my local IIS site has quit working on debug F5 startup. After a few hours of tracking things down I figured out that it is attaching to the wrong site, w3wp.exe process. I can manually attach and all is well.
If I stop the site that VS has this affinity to I get the standard ... Unable to start debugging on the web server. Unable to connect to the remote server'
Anybody know how Visual Studio chooses the w3wp.exe process that the debugger wants to attach to on debug starts?
Finally resolved after half a day of time spent and don't have an exact resolution. This project is a Web Site running on a particular port at same level as the Default Web Site. The fix was adding in the port to the project properties page 'Project Url' and removing it from showing up underneath the Default Web Site. I never thought the port was included in the project Url where the Virtual directory is created since original setup a few weeks back. If my memory is wrong then something removed the port from this Project Url setting.
I also noted that for some reason this site showed up in IIS Manager in 2 locations, under the Default Site as well as the site itself. When originally setup the Default Site was deleted and added back later but all had been working fine since then.
After more thought I also recall that the I discovered when the site did not first run in debugger it had been changed to run under IIS Express. I don't know why that happened unless I did seem sleep coding over the weekend.

Unable to remote debug a ASP.NET 5 WebApp in Azure

I created a new ASP.NET 5 RC1 WebApp using Visual Studio 2015 and published it to Azure. I turned on remote debugging and selected VS 2015 for the debugger. I can attach to the WebApp, but any breakpoint I set is not showing up completely red. Hovering over the breakpoint gives you the message "The breakpoint will not be currently hit. No symbols have been loaded for this document." I did a bunch of searches to see if anyone else had encountered this issue. I found some articles that seemed to indicate the solution:
Remote debugging Azure website: Breakpoints not hit
Azure Website Remote Debugging with git deploy not working
I tried turning off "Just my code" and adding the app setting, but neither of these worked. I even had a colleague try the same thing from his system and his Azure account to make sure it wasn't just an environmental issue on my system. Does anyone know how to fix this?
The problem is the VS 2015 Azure tooling is not yet DNX aware at the debugger level. So for now, you'll need to manually attach the debugger, using the steps documented in this article.
Once you get the list of processes, you'll want to attach to the dnx.exe process, instead of the usual w3wp.
I just tried with a new ASP.NET RC1 app, and was able to set and hit breakpoints. It took a while to attach and load symbols, so be patient :)

Unable to start debugging -visual studio 2012

I have a solution where i have 8/9 projects.
everything was working good and suddenly, I started to get an error when I start to debug. and it says
Unable to start debugging.
If I close visual studio and run it again, it works in the first try.
and after that it stops working.
In the configuration manager it is set to "Any CPU".
I tried many thing with no luck. Is there any help??
this is how the error looks like..
I got similar error:
"Unable to start debugging. Check your debugger settings by opening
project properties and navigation to 'Configuration properties --> Debugging"
I have solved it by setting :
Properties--> Debugging --> Working Directory
to $(ProjectDir)
As it's an MVC web application, there's a couple of things to check. Firstly, are you sure the web project is set as your startup (this catches me and a couple of others in my office out from time to time)?
Secondly, where are you hosting the project? Are you using Cassini, or are you hosting it in IIS while you debug? If so, check IIS and make sure that the site is started, there's no issues with the AppPool, etc.
Finally, one way to try is to actually press Ctrl+F5 to run without the debugger attached, I often find that IE will then actually display an error that's causing the issue.

Debugging a Silverlight project with a WCF service

I have a WCF service hosted in IIS which is consumed by a Silverlight client application. When I run the Silverlight application, none of the break points seem to get hit (not breakpoints in the service, although they also don't get hit. That service is not in the same solution).
Normally when I've created SL projects in the past, they hit break points by default, and I can't thing I've changed any of the settings.
When I run the project, I do get a message box saying, "The Silverlight project you are about to debug uses web services. Calls to the web service will fail unless the Silverlight project is hosted in and launched from the same web project as the web services. Do you want to debug anyway?"
So I say 'yes'.
My break point is in a place that I know gets hit (InitializeComponent in MainPage.xaml.cs), so that's not it.
I don't know if it makes a difference to the client application, but the WCF service does have within its App.config the compilation debug set to 'true'.
Can anyone help?
Edit:
Some useful points: The project is set to debug. There is no web component to the SL project. The application compiles and runs normally. The code in the screen shot below is the code behind for the main page which is the default page (and the one I see when I start the project). The Visual Studio version is 2010 Ultimate (version 10.0.40219.1 SPRel) and I am not creating an OOB application. As well as just running regularly, I have specifically started from the Debug->Start Debugging option in Visual Studio.
Screen shot:
If that image isn't clear enough, there is the full resolution one here.
Second screen shot showing a break point on the InitializeComponent in MainPage.xaml.cs which doesn't fire (the previous one showed the constructor of the related view model).
Again, if that's not clear enough, the full resolution version is here.
The message your getting is unrelated to your breakpoints not being hit. This 'warning' isn't entirely true as well, as long a the webservice you're calling is running you'll be fine. You can happily ignore this warning.
As to not hitting breakpoints, I can think of two reasons. You could be building in release mode, or you could be starting the wrong project. You should not be starting the MyApp.Web project Visual Studio probably created for you, but the actual Silverlight project.
If it isn't one of those options you should provide a bit more detail about what you're doing, like Visual Studio versions, whether you're running an out-of-browser app, does the app actually work etc. There can be a few more things to check but it hard to guess it them with this little info.
I'm not seeing a test page.htm in your solution. How are you hosting / running the SL app?
If you were hosting it in an ASP.NET web app I'd say check that the Silverlight debugger was enabled on the web project project properties.
But as it is I can't see how the silverlight app is getting run at all...?

Difficulty debugging WCF Service in Visual Studio

I think I'm having an issue where, if I set breakpoints in a ASP Azure project, the page just freezes without letting me step around in Visual Studio 2010. I'm not sure if I have a bug, or if I'm doing something wrong.
I have a Silverlight 4 app that consumes a WCF service made available from an Azure project. If I start up VS, build, and run, everything works fine. If I set a breakpoint in the service getData() method, the browser tab becomes unresponsive. If I unset the breakpoint, it remains unresponsive until I restart visual studio.
I have the Azure project set as my web role. I am able to hit breakpoints in WebRole.cs in the ASP project, but it seems like putting a breakpoint in the .svc file messes it up.
Is this a known issue? Or could I be doing something wrong?
I don't how the Azure project might effect things but but you might want to look at:
Configuring Message Logging
Service Trace Viewer Tool (SvcTraceViewer.exe)
WCF Test Client (WcfTestClient.exe)

Resources