visual-studio 调试 ASP.NET MVC 应用程序时,未命中断点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/732674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When debugging ASP.NET MVC app, breakpoints are not hit
提问by Darko Z
When trying to debug a ASP.NET MVC app, the breakpoints in my controllers arent getting hit. When entering debug mode they just show an empty red circle with a warning triangle instead of the normal full circle. This is strange because debugging was working fine until now, and no configuration changes have been made in my environment for a while.
尝试调试 ASP.NET MVC 应用程序时,我的控制器中的断点未命中。进入调试模式时,它们只显示一个带有警告三角形的空红色圆圈,而不是正常的完整圆圈。这很奇怪,因为到目前为止调试工作正常,并且有一段时间没有在我的环境中进行配置更改。
I have seen this questionand had a look at my modules view and the correct ones aren't being loaded, however I'm not sure how to remedy this. Also all the relevant pdb files are in the bin folder of the site.
我已经看到了这个问题并查看了我的模块视图并且没有加载正确的模块,但是我不确定如何解决这个问题。此外,所有相关的 pdb 文件都在站点的 bin 文件夹中。
Any suggestions on how to fix this?
对于如何解决这个问题,有任何的建议吗?
Cheers!
干杯!
EDIT:The app is running as a local site on IIS7 and I'm debugging with VS 2008
编辑:该应用程序在 IIS7 上作为本地站点运行,我正在使用 VS 2008 进行调试
回答by Darko Z
Ok so after 4 hours wasted, I find that setting my web project as the startup project solves the issue! This surely must be a bug...
好的,在浪费了 4 个小时之后,我发现将我的 web 项目设置为启动项目解决了这个问题!这肯定是个bug……
I hope I save someone out there half a day :)
我希望我能救人半天:)
回答by Simon_Weaver
Few more possibilities:
更多的可能性:
If you have a client and server in your solution (lets say a WPF and WCF app) you should make sure you select 'multiple startup projects'. [this one is similar to your accepted answer, but useful if you need a client running too]
Release mode is selected for the project. When doing a fresh get (as I discovered today) on a new machine VS seems to like to switch to 'Release' configuration profile.
如果您的解决方案中有客户端和服务器(比如 WPF 和 WCF 应用程序),您应该确保选择“多个启动项目”。[这个类似于您接受的答案,但如果您也需要运行客户端,则很有用]
为项目选择了发布模式。在新机器上进行新的获取(正如我今天发现的那样)时,VS 似乎喜欢切换到“发布”配置文件。
回答by Suamere
Some team member deleted the Debug configuration for one project (The MVC Project). Though the Solution configuration was set to "Debug / AnyCPU", if you looked in the configuration for that, the Project-Configuration for the MVC Project was set to Release, with no option for Debug, and all other projects were set as Debug appropriately.
一些团队成员删除了一个项目(MVC 项目)的调试配置。虽然解决方案配置被设置为“调试/AnyCPU”,如果你查看配置,MVC 项目的项目配置被设置为发布,没有调试选项,所有其他项目都被适当地设置为调试.
So I added Debug back to the project configurations (Just drop-down "Add"... uncheck the box to add to solution). And viola...
所以我将 Debug 添加回项目配置(只需下拉“添加”...取消选中添加到解决方案的框)。还有中提琴...
回答by Brian Ibbison
I had the same problem. Check here: Tools->Options->Debugging
我有同样的问题。在这里检查:工具->选项->调试
Fix by selecting Enable .Net Framework source stepping
通过选择启用 .Net Framework 源步进进行修复
回答by NightOwl888
None of these answers helped me. Some of my breakpoints were hit, and some not. But I discovered the problem in my case.
这些答案都没有帮助我。我的一些断点被命中,有些没有。但是我在我的案例中发现了这个问题。
If there is a file at the exact same virtual location with the exact same name as the URL you are trying to debug, the file will be served to the browser automatically by IIS and the breakpoint will not be hit because no MVC code actually runs.
如果在与您尝试调试的 URL 完全相同的虚拟位置上有一个文件,该文件将自动由 IIS 提供给浏览器,并且不会命中断点,因为没有实际运行 MVC 代码。
回答by George Stocker
Things to try:
尝试的事情:
Clean the Solution, then rebuild it.
If that doesn't work, close the solution, delete the
binandobjfolders, and rebuild.- If that doesn't work, restart the IDE after doing step #2.
- If you're debugging an ASP.NET project hosted by IIS, make sure you're attached to the correct process (
w3wp.exe).
清洁解决方案,然后重建它。
如果这不起作用,请关闭解决方案,删除
bin和obj文件夹,然后重新构建。- 如果这不起作用,请在执行第 2 步后重新启动 IDE。
- 如果您正在调试由 IIS 托管的 ASP.NET 项目,请确保您已附加到正确的进程 (
w3wp.exe)。
回答by SirDemon
The following has worked for me most of the time when I had this problem:
当我遇到这个问题时,以下大部分时间对我有用:
Find where your projects dll cache is being held (usually in ASP.NET Temprorary Files). Then close VS, do an IISRESET /stop (if you're using IIS), delete all the files in dll cache. Do an IISRESET, start VS, open your project and rebuild it.
查找您的项目 dll 缓存所在的位置(通常在 ASP.NET 临时文件中)。然后关闭 VS,执行 IISRESET /stop(如果您使用的是 IIS),删除 dll 缓存中的所有文件。做一个 IISRESET,启动 VS,打开你的项目并重建它。
回答by Muhamed Shafeeq
Change in Visual Studio Header Release option to Debug
将 Visual Studio Header Release 选项更改为 Debug
回答by JohnWrensby
I had Shelved my changes in TFS and had a breakpoint set on a shelved cs file that was not part of the solution anymore. Once I retrieved my Shelveset, everything worked.
我在 TFS 中搁置了我的更改,并在搁置的 cs 文件上设置了一个断点,该文件不再是解决方案的一部分。一旦我取回了我的书架,一切正常。
回答by Tom
Quick fix...
快速解决...
Run my project in Debug. Cleaned and rebuild solution (MVC).
在调试中运行我的项目。清理和重建解决方案 (MVC)。
Re run the UI project and the Breakpoints started working again.
重新运行 UI 项目,断点再次开始工作。
Hope this will help someone.
希望这会帮助某人。

