visual-studio 为什么调试器不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2417036/
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
Why the debugger doesn't work
提问by Gaby
My debugger is not working,
I'm putting a breakpoint, but in run, time visual studio doesn't stop on the breakPoint.
How to fix it?
There is nothing special in my application, it is a simple web application.
I am using visual studio 2005.
我的调试器不工作,
我设置了一个断点,但在运行中,时间 Visual Studio 不会在断点处停止。
如何解决?
我的应用程序没有什么特别之处,它是一个简单的 Web 应用程序。我正在使用 Visual Studio 2005。
I've created a new web application project, and on the default.aspx page there is a obout grid control, on the default.cs i am filling a datatable and putting it as datatasource for the grid.
I was able to debug it, suddenly the debugger is never hit.
note that the debugger is on the load event.
我创建了一个新的 Web 应用程序项目,在 default.aspx 页面上有一个 obout 网格控件,在 default.cs 上我正在填充一个数据表并将其作为网格的数据源。
我能够调试它,突然间调试器从未被击中。
请注意,调试器在加载事件上。
采纳答案by Gaby
Find below the steps that solved my problem:
在下面找到解决我的问题的步骤:
- Delete ASP.NET temporary files from
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files - Change build configuration to debug from project properties.
- Delete bin folder from your project.
- Check if compilation debug is set to true in the web.config
- iisreset
- Rebuild the project.
- 删除 ASP.NET 临时文件
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files - 更改构建配置以从项目属性进行调试。
- 从您的项目中删除 bin 文件夹。
- 检查 web.config 中的编译调试是否设置为 true
- 重置
- 重建项目。
回答by Andrew Hare
There are a couple of things that could be wrong:
有几件事可能是错误的:
- Your source code and assembly could be out of sync - rebuild the application and try again.
- You could be attached to the wrong process - check to see what process you are attached to.
- There could be a logical error in your code that is causing your breakpoint to not be hit (i.e. the method you are in is not actually called, logical branching is routing control around the breakpoint, etc.)
- 您的源代码和程序集可能不同步 - 重建应用程序并重试。
- 您可能附加到错误的进程 - 检查以查看您附加到的进程。
- 您的代码中可能存在逻辑错误,导致您的断点未命中(即实际上并未调用您所在的方法,逻辑分支是围绕断点进行路由控制等)
回答by Gerrie Schenck
The symbols probably aren't loaded, that's why the breakpoint won't be hit. Did you set the website as the startup project?
符号可能没有加载,这就是断点不会被命中的原因。您是否将网站设置为启动项目?
When debugging, what process it attached? It should be w3wp.exe if you want to debug asp.net code.
调试时,它附加了什么进程?如果要调试asp.net 代码,应该是w3wp.exe。
回答by Aim Kai
You might need to set your application in web config so that it can be debugged..
您可能需要在 web 配置中设置您的应用程序,以便它可以被调试..
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
回答by Arun Prasad E S
Break point was not getting hit, i cleaned and rebuild, but still not hitting,
I just reopened the page (In my case Controller) and started working fine..
断点没有被击中,我清理并重建,但仍然没有击中,
我只是重新打开页面(在我的情况下是控制器)并开始正常工作..
回答by mrosiak
When everything failed try this: Right mouse button on your project -> Build -> untick 'Optimize code'
当一切都失败时,试试这个:在你的项目上单击鼠标右键 -> 构建 -> 取消勾选“优化代码”
Or
或者
I had similar problems when I've installed dotPeek and maybe because I don't have Resharper it was loading symbols from dotPeek symbol server but it couldn't hit my breakpoint. In that case Open dotPeek and click on Stop Symbol Server.
我在安装 dotPeek 时遇到了类似的问题,也许是因为我没有 Resharper,它正在从 dotPeek 符号服务器加载符号,但它无法达到我的断点。在这种情况下,打开 dotPeek 并单击停止符号服务器。
回答by DOK
You need to be running in Debug mode, and not Release mode.
您需要在调试模式下运行,而不是在发布模式下运行。
Here's a detailed article about How to: Enable Debugging for ASP.NET ApplicationsBasically, you can either set debug mode in project properties or in web.config.
这里有一篇关于如何:为 ASP.NET 应用程序启用调试的详细文章基本上,您可以在项目属性或 web.config 中设置调试模式。
回答by Rahav
This can occur when Visual Studio is set to debug Managed codebut the code is not managed (managed code is running under the control of the common language runtime (CLR)).
当 Visual Studio 设置为调试托管代码但代码未托管(托管代码在公共语言运行时 (CLR) 的控制下运行)时,可能会发生这种情况。
To fix the problem change the debug mode as shown in the right hand side of the figure below to Native only, Mixed, or Auto.

要解决此问题,请将下图右侧所示的调试模式更改为Native only、Mixed或Auto。

Side note: I recommend not choosing Mixed unless your system has both managed and native code (code that does not run under the CLR) because Visual Studio can't attach to an already running process in mixed mode. To debug an already running code Visual Studio need to be set to debug in Native onlyor Managed only.
旁注:除非您的系统同时具有托管代码和本机代码(不在 CLR 下运行的代码),否则我建议不要选择混合,因为 Visual Studio 无法以混合模式附加到已运行的进程。要调试已运行的代码,Visual Studio 需要设置为仅在Native或Managed 中调试。
回答by Davide Cannizzo
I've seen the already existing answers have listed many possible causes, but I'd like to add one more: if you're using post-compilation tools (such as ILMerge), check whether those tools keep your debugging information (is there a .pdbfile? or maybe you have embedded it in your compilation output). For those ones who are actually using AfterBuildtasks in their .csprojI really suggest to check out.
我已经看到已经存在的答案列出了许多可能的原因,但我想再添加一个:如果您使用的是编译后工具(例如 ILMerge),请检查这些工具是否保留了您的调试信息(是否有一个.pdb文件?或者您可能已经将它嵌入到您的编译输出中)。对于那些实际AfterBuild在他们的任务中使用的人,.csproj我真的建议检查一下。

