简体   繁体   中英

Visual Studio C# debugger - the breakpoint will not currently be hit

I know that this question has been asked several times, and many people here have suggested different answers. Though none of them are working for me.

I created a Windows Forms application with Visual Studio and .NET framework 4.0 and added a breakpoint. However, when I debug the application, an exclamation mark appears on the breakpoint and it says..

The breakpoint will not currently be hit. No executable code is associated with this line. Possible causes include: conditional compilation or compiler optimizations.

I have tried out several suggested solutions

  • Cleaned the project
  • Deleted the pdb
  • Checked the configuration and ensured that it is debug
  • Set the debug configuration from "x86" to "Any CPU"
  • Tried creating project from scratch
  • Tried re-installing .NET framework
  • Removed temporary ASP.NET files

However, none of them seems to be working. I was able to debug my projects with breakpoints before and for some reason, something happened and I am not able to debug the projects any more. What should I look out for or fix to resolve this issue?

Probably your breakpoint is in a project which is not dependent on the "startup project". Implicitly these projects are not compiled on Run (button F5 ).

Go to: menu ToolsOptionsProject and SolutionsBuild and Run → uncheck first check box ( only build startup projects and dependencies on Run ).

In Visual Studio go to the menubar, menu DebugWindowsModules , find the assembly your code is located in and check the Symbol state. Chances are you're having Visual Studio loading a different version not matching your PDB files.

I recently had this problem and it stumped me for a while. Ends up I had inadvertently switched my build configuration away from DEBUG to another configuration that was more optimized and did not "Define DEBUG constant": Project > Properties > Build > (first check box).

This may also happen if other projects in your solution are set to configurations other than DEBUG, usually accidentally, in the Solution Configuration Manager.

I had the same problem here...

I was using Visual Studio 2005 - Professional Edition, and my problem was when I tried to breakpoint a Windows Forms application.

I've searched in many forums on the Internet, and I hadn't found any answer. But the solution for this problem was easier than I had expected. Just right click on a Visual Studio shortcut (or .exe) and unmark execute in compatibility mode .

Your best option is to create a new project. Then import all the files in the previous project, including your forms if any.

You are now set to OK to continue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM