2

I'm debugging .Net Core in Visual Studio, and the breakpoints are working fine in the current file, but when a method from a different file is called, its breakpoints aren't being hit. I'm not familiar with Visual Studio because I usually debug in VS Code so I'm sort of lost.

I've googled it, but can't find any info - is it possible that VS ignores breakpoints in files other than the current one?

(It's ignoring the Debug.WriteLine I added as well but I just need to confirm if it's really not hitting breakpoints rather than not actually calling the method.)

half of a glazier
  • 1,864
  • 2
  • 15
  • 45
  • are you using mixed managed and unmanaged code? In that case you must select debug mode as mixed, otherwise it won't break – phuclv Mar 29 '20 at 14:43
  • um... how do I do that? – half of a glazier Mar 29 '20 at 14:46
  • https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-in-mixed-mode?view=vs-2019 – phuclv Mar 29 '20 at 14:46
  • Did you use an old project? What is the type of different file or just as phuclv said, a c# project references a c++ dll? If not, please try to delete `bin`, `obj` file and then cpy the dll and pdb into the output folder from [this link](https://stackoverflow.com/questions/16546703/visual-studio-debugging-a-referenced-dll-i-have-source-in-another-sln). Please let us know if it does help. – LoLance Mar 30 '20 at 09:45

1 Answers1

0

Visual Studio ignores breakpoints in different file

If this issue is as phuclv's descroption, a net core project references a c++ Dynamic link library, you can follow the link, open the c++ project-->change it as mixed and then open net core project, choose Enable native code debugging. Also,

If you create the project in vs-code and then migrate it into VS2019,since vs-code is different from visual studio, you should try these steps:

1) delete the bin and obj folder first

2) make sure that these two options are checked under Tools-->Options-->Nuget Package Manager.

enter image description here

3) Try disabling Just My Code under Tools--> Options --> Debugging-->General

4) If the file is from the other project,please add reference to these projects by Right-click on the Dependencies-->Add Reference-->these projects or just copy these projects's dll and pdb files into the main project's output folder(Bin).

5) Use Debug mode to debug your project.

In addition, if these do not work, please try to create a new net core project in vs and migrate your old project into the new project to test whether this issue persists.

LoLance
  • 25,666
  • 1
  • 39
  • 73