How do I remedy the “The breakpoint will not curre

2018-12-31 03:14发布

C# desktop application on express edition. Worked then didn't work 5 seconds later.

I tried the following.

  • Ensure debug configuration, debug flag, and full debug info are set on all assemblies.
  • Delete all bin and obj folders and all DLLs related to the project from my entire machine.
  • Recreate projects causing the problem from scratch.
  • Reboot.

I have two WinForms projects in the solution. One of them loads the debug info, one doesn't. They both refer to the assembly I'm trying to get debug info on in exactly the same way in the project file. Any ideas?


I want to add in here, mostly for myself when I come back to review this question, that symbols are not loaded until the assembly is loaded, and the assembly is not loaded until it is needed. If the breakpoint is in a library that is only used in one function in your main assembly, the symbols will not be loaded (and it will show the breakpoint as not being hit) until that function is called.

30条回答
有味是清欢
2楼-- · 2018-12-31 03:57

Sometimes, even though it gives you this error, the breakpoint still gets hit, so just ignore the error. This happens fairly often in the Views of an MVC web app.

查看更多
看风景的人
3楼-- · 2018-12-31 03:58

Webapplications (IIS Express) only:

  • Rightclick IIS Express Tray and close the IIS.
  • Clean Solution

IIS Tray

查看更多
姐姐魅力值爆表
4楼-- · 2018-12-31 04:01

Check if your .pbd file is missing in your bin/Debug folder. If it is then go to "Properties" of your project, selected "Build" and then "Advanced" at the bottom. Choose "full" under "Debug info" in the new window that appeared. This was my issue and solved it for me.

Showing where to find the setting

查看更多
墨雨无痕
5楼-- · 2018-12-31 04:02

Things to check just to be clear: Make sure you have the configuration set to 'Debug' and not 'Release'. You can debug the startup project in 'Release' mode, but not a referenced class library.

查看更多
美炸的是我
6楼-- · 2018-12-31 04:02

I have read carefully all the answers above, but none of them solved my problem.

In my case, I was compiling a class library (DLL). No modules seem to be loaded in Debug -> Modules, so I couldn't even load the symbols manually.

My solution was to add this line to my code:

System.Diagnostics.Debugger.Launch();

Once this code is reached, an exception is triggered and .NET Framework shows a dialog box asking which Visual Studio (i.e. new instance of VS 2008, new instance of VS 2013, etc) you want to use to debug the program. You can choose the existing instance of VS with your project loaded. This will attach the process to your VS session and load all symbols, and now you can debug your project.

Of course, the compilation has to be done using the Debug configuration, not Release.

查看更多
余生请多指教
7楼-- · 2018-12-31 04:03

Debug > Windows > Modules to see what modules were being loaded put me in the right direction.

In my case IIS Express seemed to be loading a different DLL from the temporary ASP.NET files.

The solution?

  1. Browse to C:\Users\<YOUR USER>\AppData\Local\Temp\Temporary ASP.NET Files\vs
  2. Delete everything in this directory!
查看更多
登录 后发表回答