Visual Studio ignoring breakpoints - visual-studio

Visual Studio is ignoring my breakpoints. I don't know if it makes a difference but this is happening in Web API. I know it's passing over my code because I can put Console.WriteLine('FOO'); in and it shows up. But it passes over my breakpoints like they aren't even there. I added System.Diagnostics.Debugger.Break(); and that gives me this dialog even though I opened Visual Studio as an administrator.
I'm starting the Web API project directly. That is, I'm not starting a project that uses Web API and therefore need to right click Solution > Startup Projects and set Web API to start. The project is in debug mode. I've cleaned my solution, restarted IIS, and closed and reopened Visual Studio.
Also, I can open other projects, like an ASP.NET MVC app, and the breakpoints work fine there. It's just Web API. Any idea what I am doing wrong?

Restart your computer.
I don't know what the exact cause was but after trying everything else I restarted and now it works.
Also, I had to run it from another project. If I debug the Web API project it doesn't hit the breakpoints but if I debug from the Web UI project (Web API is part of that solution) it works.
edit
And actually that only worked like one time. I ended up including Web API in startup projects and also copying the dll and pdb to c:\mySymbols on each build via post build commands copy c:\path\the.dll c:\mySmbols\the.dll and then going to debug > options > debugging > symbols and adding the path to c:\mySymbols to the list.
edit
Another thing is I was trying to use a custom request validator via
<httpRuntime requestValidationMode="4.5" executionTimeout="300" maxRequestLength="51200" requestValidationType="MyProj.App_Code.CustomRequestValidator" />
and that definitely breaks it. So I had to take that out too (at least until I figure this problem out).
I'm not sure which, if any of these things did the trick but it is working now.

Related

Debug Multiple Microservices in Visual Studio

I have a solution which contains two microservices and an API gateway. While debugging, the solution requires to run again and again to get insights or fix bugs.
I have tried dotnet watch run but with this I can attach debugger to one project at a time.
Hosting applications on IIS also requires to copy the files to folder every time for small changes as compared to in .NET Framework where it was easier to host applications on localhost and attach to process.
Currently, I have been debugging it using visual studio with multiple startup projects.
Since pressing F5 constantly is repetitive and hectic so is there any other way around to debug multiple projects using dotnet watch or IIS or anything else?
ctrl+F5 can run multiple, but it will not debug. Other solution try run multiple VS studio, but I'm not sure
There is possibly another way. I was also had issues running multiple projects to debug microservices.
I explored a few possibilities:
Docker - didn't help and ate more memory (if our whole stack was .net core this might be the goto)
Auto starting VS projects with a script (better but not quiet the level of control we needed)
Researched all the things that people said (use logging, do tests etc, all of which ignore the fact that we don't all have perfect codebases to work in)
Finally I created something that works well for our team, and maybe it'd work for you?
Dev Launcher is a simple command line utility that you configure with your project information. It's currently aimed at handling .net full framework, runs in (Visual Studio) and .net core runs with (Visual Studio or dotnet run). It is configurable and I'm guessing a person could get it to work with other IDE's such as VS Code, though I haven't tried it.
The main concept is you first choose the projects you'd like to open for debugging. These projects will open in the IDE which is configured (Defaults to Visual Studio). Then you choose the supporting microservices that you'd like to run in the background. If these are written in .net core they will run in a console window, freeing the memory that would normally be consumed by the IDE and debugger.
Curious to see if that'd be helpful for your situation. Also curious what other ideas people have to make debugging multiple microservices better...

Unable to Debug a Website in Visual Studios

Here is my situation...
I have to maintain a website with multiple applications. We no longer have any of the solution files and the code is deployment code (so it uses DLL's instead of the original classes).
I basically grab the code from the website and stick it in a Visual Studio projects folder (This is generally C# code with Javascript that was originally developed on VS). I then open Visual Studios's 2010 Professional (VS) and open website, using the path in the project folder. I then add references to all the DLL files and if all the includes, images , and css files paths are referenced correctly, I can hit F5 and get the webpage to appear with some functionality. This creates a Project file in the Projects folder which I can then open instead of opening a website.
The problem is that I am unable to debug. If I set a breakpoint, it goes from solid red to outline red upon start of debugging. The standard message is "The breakpoint will not be currently hit. No symbols have been loaded for this document".
I have cleared out the symbols and reloaded.
I have debug = true in all my Web.config files.
I have gone into project properties and set the startup project action to "Start".
Any ideas why I can't debug ? My other projects that I develop from scratch work fine, but it is these projects that I am trying to get working from website files that won't debug.
My goal is to get every one of the Website apps under VS control were I can fix bugs and make improvements. Not very easy when the original source code is no longer available.
Please Help !
Thank You,
Eric
I fought this issue for a half of a day. I'm currently maintaining a website application. What worked for me is going into the project's Property Pages >> Start Options and changing the server to "Use Custom Server". I believe this setting will use IIS and not IIS Express. I started the project and was immediately able to debug.

Visual Studio keeps requesting missing web components

When I open a particular mvc 3 website project in VS 2010 I get the following message:
The Web Project "X" requires missing web components to run with Visual Studio. Would you like to download and install them using the Web Platform Installer now?
ASP.NET Web pages with Razor syntax.
When I click yes
The web platform installer shows with the message that "0" items need to be installed.
My other mvc 3 projects do not show this behavior
Not a major inconvenience, but still...
thoughts any one?
I got the same error after reinstalling my computer.
I came to this conclusion, VS needs IISExpress to load my additional project. The addition projects has a webservice and it can run locally. Even if my endpoints points to a local address it still needs the IISExpress (standard IIS 7.5 does not respond the endpoint request) to open from VS (im running VS2010).
So after installing IISExpress i could reload my project in VS.
C.,
That shouldn't happen, and it would be interesting to figure out why. In the meantime, you should be able to turn this off by unchecking the "Package Restore" checkbox in Visual Studio's Options dialog. (Select "Package Manager" in the tree view to find it.)
If it's happening only for specific projects, you can solve this more surgically by removing the packages.config file for the affected project. In fact, if you want to do root cause analysis, you should look into why that file exists and how it got there.
HTH,
Clay

Visual Studio 2010 gets stuck with solution with MVC3 Razor and Azure

I've a solution with several .dll projects, an Asp.NET MVC3 Razor project and an Cloud project.
If I try to compile the solution with the Cloud project loaded, VS2010 gets stuck in "Buil started".
I have to forcefully close VS2010 killing the process and restart. Then the compiling works good once, the next time it will get stuck again.
If I unload the project and set the mvc project as start-up, everything works (but azure of course).
What could be the problem?
Cheers.
Was it by any chance an ASP.NET MVC project to which you added a CloudService project later on or did you start off with a CloudService from the very beginning?
I was in the former situation and I had no end of problems, like not being able to open property pages or deploying the application. It's not quite your issue, but the following article might help:
http://tomkrueger.wordpress.com/2010/07/27/azure-deployment-issue-after-upgrading-to-visual-studio-2010-and-net-4-0/
As I say, my problems started because I actually added an Azure project to an existing ASP.NET MVC solution and there were some unnecessary settings left over in the web.csproj file.
All I had to do was open web.csproj in notepad and remove all occurrences of the <PlatformTarget> element.
My MVC prjoject was x86 and of course Azure works on x64 only. Even though I had the platform target set up as AnyCPU somehow Azure couldn't quite get along with it.
Maybe cleaning up your project files helps as well.

Visual Studio 2010 Debugging issue

I have a problem with debugging my Silverlight 4 (hosted in ASP.NET MVC2) in Visual Studio 2010. It was working fine until I tried remote debugging. After a lot of hassle I managed to configure remote debugging but it worked only occasionally. So I created a new app and copied my classes one by one, but now I see I cannot debug not only remotely but also "locally" in development server. Breakpoints in Silverlight code says "The breakpoint will not currently be hit. No symbols have been loaded for this document." Strangely enough, if I run my app it will show my previous code results. (It may be relevant, before this problem I noticed that my app doesn't update immediately when I publish to remote web server. So I did the following for all projects in the solution:
//In AssemblyInfo.cs in Properties folder
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]
I'm adviced that it will automatically generate version numbers so, when I publish to remote server it will immediately take into effect, which seems working well.)
However, if I change development server's port number, in the properties page of my ASP.NET MVC app, then I'm able to debug locally (about remote debugging I just gave up). But, it didn't last long; after some updates in my code the problem suddenly reoccurs. I guess development server deploys my app somewhere in a folder per port number, but where? May be, if I delete that folder, will the problem be solved? Can somebody advice me what to do?
There seems to be bug in Visual Studio 2010; see:
silverlight 4, dynamically loading xap modules

Resources