简体   繁体   English

为什么调试器不起作用

[英]Why the debugger doesn't work

My debugger is not working,我的调试器不工作,
I'm putting a breakpoint, but in run, time visual studio doesn't stop on the breakPoint.我设置了一个断点,但在运行中,时间 Visual Studio 不会在断点处停止。
How to fix it?如何解决?
There is nothing special in my application, it is a simple web application.我的应用程序没有什么特别之处,它是一个简单的 Web 应用程序。 I am using visual studio 2005.我正在使用 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.我创建了一个新的 Web 应用程序项目,在 default.aspx 页面上有一个 obout 网格控件,在 default.cs 上我正在填充一个数据表并将其作为网格的数据源。
I was able to debug it, suddenly the debugger is never hit.我能够调试它,突然间调试器从未被击中。
note that the debugger is on the load event.请注意,调试器在加载事件上。

Find below the steps that solved my problem:在下面找到解决我的问题的步骤:

  1. Delete ASP.NET temporary files from C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET FilesC:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files删除 ASP.NET 临时文件
  2. Change build configuration to debug from project properties.更改构建配置以从项目属性进行调试。
  3. Delete bin folder from your project.从您的项目中删除 bin 文件夹。
  4. Check if compilation debug is set to true in the web.config检查 web.config 中的编译调试是否设置为 true
  5. iisreset 重置
  6. Rebuild the project.重建项目。

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 (ie the method you are in is not actually called, logical branching is routing control around the breakpoint, etc.)您的代码中可能存在逻辑错误,导致您的断点未命中(即实际上并未调用您所在的方法,逻辑分支是围绕断点进行路由控制等)

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 ..我刚刚重新打开页面(在我的情况下是控制器)并开始正常工作..

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。

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>

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.我在安装 dotPeek 时遇到了类似的问题,也许是因为我没有 Resharper,它正在从 dotPeek 符号服务器加载符号,但它无法达到我的断点。 In that case Open dotPeek and click on Stop Symbol Server.在这种情况下,打开 dotPeek 并单击停止符号服务器。

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 Applications Basically, you can either set debug mode in project properties or in web.config.这里有一篇关于如何:为 ASP.NET 应用程序启用调试的详细文章基本上,您可以在项目属性或 web.config 中设置调试模式。

尝试取消选中项目属性中的“启用 Visual Studio 托管进程”-> 调试对我有用

做一个Clean Project ,并确保您单击Debug ,而不是Run

This can occur when Visual Studio is set to debug Managed code but 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 onlyMixedAuto 在此处输入图片说明

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.旁注:除非您的系统同时具有托管代码和本机代码(不在 CLR 下运行的代码),否则我建议不要选择混合,因为 Visual Studio 无法以混合模式附加到已运行的进程。 To debug an already running code Visual Studio need to be set to debug in Native only or Managed only .要调试已运行的代码,需要将 Visual Studio 设置为NativeManaged 中调试。

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 .pdb file? or maybe you have embedded it in your compilation output).我已经看到已经存在的答案列出了许多可能的原因,但我想再添加一个:如果您使用的是编译后工具(例如 ILMerge),请检查这些工具是否保留了您的调试信息(是否有.pdb文件?或者您可能已将其嵌入到编译输出中)。 For those ones who are actually using AfterBuild tasks in their .csproj I really suggest to check out.对于那些在他们的.csproj中实际使用AfterBuild任务的人,我真的建议检查一下。

You can enable Debug as below steps.您可以按以下步骤启用调试。

1) Right click project solution
2) Select Debug( can find left side)
3) select Debug in Configuration dropdown.

Now run your solution.现在运行您的解决方案。 It will hit breakpoint.它会遇到断点。 在此处输入图片说明

I had the same issue on Visual Studio 2019 only o realize that when I set the web project as a startup project, VS didn't automatically set the Default page. 我在Visual Studio 2019上遇到了相同的问题,只是意识到当我将Web项目设置为启动项目时,VS不会自动设置默认页面。 I had to manually set my Default.aspx as the startup page and this solved my issue. 我必须手动将Default.aspx设置为启动页面,这解决了我的问题。

Are you debugging using IIS Express instead of IIS Local.您是否使用 IIS Express 而不是 IIS Local 进行调试。 I found IIS Express sometime won't hit debug points, IIS Local works fine.我发现 IIS Express 有时不会达到调试点,IIS Local 工作正常。

You could be like me to have both a production version (installed via a msi file) and a development version (opened in Visual Studio), and that is why I cannot get some of my breakpoints in the VS triggered today.您可能像我一样拥有生产版本(通过 msi 文件安装)和开发版本(在 Visual Studio 中打开),这就是为什么我今天无法在 VS 中触发某些断点。

If that is the case you need to uninstall the production version as I think some of the dll files are interfering with my debugging session.如果是这种情况,您需要卸载生产版本,因为我认为某些 dll 文件会干扰我的调试会话。

Clean and Rebuild your solution afterwards should fix the issue.之后清理并重建您的解决方案应该可以解决问题。

In Visual Studio 2010在 Visual Studio 2010 中

  1. Select Build > Clean {Project Name}选择 Build > Clean {Project Name}
  2. Rebuild Project重建项目

Now Try to rebuild project and try debug现在尝试重建项目并尝试调试

All the best祝一切顺利

After installing following add-on it started working.安装以下附加组件后,它开始工作。 After installing, restart visual studio once.安装后,重启visual studio一次。 Install plug-in as per VS version.根据VS版本安装插件。

https://download.qt.io/official_releases/vsaddin/ https://download.qt.io/official_releases/vsaddin/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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