Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2019 not entering break point in Azure Functions local debugging mode

I have accidentally made a setting change to VS2019 and I can't get back to how it was.I was debugging a Azure Functions project with out any problems. I was trying to set up the project to use XUnit to test the functions and set the appropriate start-up projects. I couldn't get the azure functions project to hit debug breakpoints. In the end I gave up and decided to use two instances of VS2019 but now I can't hit any breakpoints int the Azure Function app. I also noticed the command prompt window which starts when you run the app doesn't shut down when you click stop in visual studio. I saw a SO question saying to check:

Use Managed Compatibility Mode.//should be Unchecked

And unchecked which it is. Any ideas on what setting is incorrect?

like image 615
Paul Stanley Avatar asked Aug 09 '19 13:08

Paul Stanley


People also ask

How do I Debug Azure function locally in Visual Studio code?

In Visual Studio Code, press F5 to launch the debugger and attach to the Azure Functions host. You could also use the Debug > Start Debugging menu command. Output from the Functions Core tools appears in the Terminal panel.

Why is my breakpoint not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

How do I add breakpoints in Visual Studio 2019?

To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.


Video Answer


1 Answers

TLDR: Uncheck the "Automatically close..." option in the image below.

I have encountered the same problem with Azure Function projects, and found a solution to this. Symptoms:

  • Breakpoints are not being hit (silently ignored by VS)
  • Adding a breakpoint during debug gives a white breakpoint and "Breakpoint wont be hit..." message

The reason for this is that modules are not being loaded. This can be confirmed by opening the "Modules" window in VS during debugging (ctrl+alt+U, or search for it in top right). This window was empty for me (but filled with references if i was debugging a console application for example).

To get module loading to work, i had to uncheck the debugging-option "Automatically close the console when debugging stops". And suddenly my modules-window was filled during debugging, and breakpoints working.

enter image description here

like image 100
BobbyTables Avatar answered Sep 23 '22 17:09

BobbyTables