C# 无法调试 - “当前不会命中断点。没有为此文档加载符号”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/389290/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 01:36:02  来源:igfitidea点击:

Can't debug - "The breakpoint will not currently be hit. No symbols have been loaded for this document"

c#.netasp.netdebugging

提问by Bill Martin

I'm getting the error in the subject line. I'm running vs2k8 on server 2k3sp2. I've tried deleting the pdbs, cache directories, verifying that debugging is set up on the specific page. The interesting thing is other pages debug just fine. Just when I go to this one page. Must be a configuration issue but the page directive looks like this:

我在主题行中收到错误消息。我在服务器 2k3sp2 上运行 vs2k8。我试过删除 pdbs、缓存目录,验证在特定页面上设置了调试。有趣的是其他页面调试就好了。就在我翻到这一页的时候。一定是配置问题,但页面指令如下所示:

print("<%@ Page Language='C#' AutoEventWireup='true' CodeBehind='MemberSearch.aspx.cs' Inherits='SurencyPortal.EmployerPortal.MemberSearch' Debug='true' %>");

print("<%@ Page Language='C#' AutoEventWireup='true' CodeBehind='MemberSearch.aspx.cs' Inherits='SurencyPortal.EmployerPortal.MemberSearch' Debug='true' %>");

I've also noticed that when debugging, if I open the modules window, almost all of the symbols show a status of 'Symbol not loaded'. However, after more research from the msdn article below, one of the MSFT posts said that if it's a core .net dll, it will not load symbols so I'm not worried about that. Some of the microsoft modules (like System.Enterpricesservices.wrapper.dll) show an exclamation point with the message 'the module did not load at the default load address'. Not sure why that dll is there as I don't know of any calls to it.

我还注意到,在调试时,如果我打开模块窗口,几乎所有符号都显示“符号未加载”状态。但是,在对下面的 msdn 文章进行了更多研究之后,MSFT 的其中一篇帖子说,如果它是核心 .net dll,它将不会加载符号,所以我并不担心。一些 Microsoft 模块(如 System.Enterpricesservices.wrapper.dll)显示带有“模块未在默认加载地址加载”消息的感叹号。不知道为什么那个 dll 在那里,因为我不知道对它的任何调用。

Here are the thing's i've tried:

这是我尝试过的事情:

Breakpoint not hooked up when debugging in VS.Net 2005

在 VS.Net 2005 中调试时未连接断点

http://social.msdn.microsoft.com/Forums/en-US/vbide/thread/557fdedb-268e-48a8-9944-29b2b4e0dec2/#page:3

http://social.msdn.microsoft.com/Forums/en-US/vbide/thread/557fdedb-268e-48a8-9944-29b2b4e0dec2/#page:3

Bill

账单

回答by Bryan Rehbein

I usually see this error pop up when I am working with two separate web 'sites'. I have a web front end and a web service back end. If the development server isn't running for the 'site' the code file is for, then you will receive that error message.

当我使用两个单独的网站“站点”时,我通常会看到此错误弹出。我有一个 Web 前端和一个 Web 服务后端。如果开发服务器没有为代码文件所针对的“站点”运行,那么您将收到该错误消息。

This may not be your problem exactly, however this is usually the situation when I see that error message. Another thing you can do is Debug -> Attach to Process if the debugger isn't attached to the correct process.

这可能不是您的问题,但是当我看到该错误消息时通常是这种情况。如果调试器未连接到正确的进程,您可以做的另一件事是 Debug -> Attach to Process。

回答by Darren Kopp

Usually this happens when the .pdb files that VS is using for debugging are different than what the code is actually executing. That is, if you have made changes to your assembly.
Also, make sure that you have <compilation debug="true">in the web.config. I don't know if it has any bearing on the page directive, but that's usually what does it for me :)

通常,当 VS 用于调试的 .pdb 文件与实际执行的代码不同时,就会发生这种情况。也就是说,如果您对程序集进行了更改。
另外,请确保您<compilation debug="true">在 web.config 中有。我不知道它是否与页面指令有任何关系,但这通常对我有用:)

回答by Andrew Cowenhoven

I agree that I have seen this when I have multiple assemblies that are out of sync and/or one or more pdbs do not match the source. In my case, it was because I had a weirdness with my version control software (ClearCase) and I was not actually compiling what I thought I was.

我同意,当我有多个不同步的程序集和/或一个或多个 pdb 与源不匹配时,我已经看到了这一点。就我而言,这是因为我的版本控制软件 (ClearCase) 很奇怪,而且我实际上并没有按照我的想法进行编译。

回答by Steve Steiner

Place an inline break statementto be sure you are actually running the code. If you do not stop then it is likely the code you are attempting to debug is just not being run, or you are not debugging it with a managed debugger.

放置一个内联break 语句以确保您确实在运行代码。如果您不停止,那么您尝试调试的代码很可能没有运行,或者您没有使用托管调试器调试它。

If you do stop but cannot find source, then you likely do not have a pdb for the module. Check the top of the callstack window to see which assembly contains the method you stopped in. That is the assembly for which you need a pdb. The module window will show the location on disk of that assembly. The command line tool "dumpbin -headers assembly.dll" will dump the PE headers. Check the Debug Directory to see where the pdb was placed when the assembly was built. If the Debug Directory does not exist then the assembly was built without debug information. If that is the case your problem is then to determine why that specific assembly was built without debug info. If it did have debug information and a pdb exists, but is not being loaded then it means either the pdb wasn't found by the debugger and you should look at the tools\options\debug\symbol settings. Or the pdb and assembly do not match. If the timestamps are not within 1 sec then they certainly don't match.

如果您确实停止但找不到源代码,那么您可能没有该模块的 pdb。检查调用堆栈窗口的顶部以查看哪个程序集包含您停止的方法。这就是您需要 pdb 的程序集。模块窗口将显示该程序集在磁盘上的位置。命令行工具“dumpbin -headers assembly.dll”将转储 PE 标头。检查调试目录以查看构建程序集时 pdb 的放置位置。如果调试目录不存在,那么程序集是在没有调试信息的情况下构建的。如果是这种情况,那么您的问题是确定为什么在没有调试信息的情况下构建特定程序集。如果它确实有调试信息并且 pdb 存在,但没有被加载,那么这意味着 pdb 不是 t 由调试器找到,您应该查看 tools\options\debug\symbol 设置。或者 pdb 和程序集不匹配。如果时间戳不在 1 秒内,那么它们肯定不匹配。

If the above doesn't help please update with more information.

如果以上没有帮助,请更新更多信息。

回答by ChrisPelatari

The only time I've ever run into an issue like this is if I was trying to debug while the project was in release mode.

我遇到过这样的问题的唯一一次是我在项目处于发布模式时尝试调试。

回答by Jamie Clayton

If you have a "WebSite" project, rather than "WebApplication", I've found that overlapping code file classes can cause the issue. There are a few ways this can happen. Unfortunately Visual Studio still seems to compile the solution/project without error.

如果您有一个“WebSite”项目,而不是“WebApplication”,我发现重叠的代码文件类可能会导致问题。有几种方法可能会发生这种情况。不幸的是,Visual Studio 似乎仍然可以毫无错误地编译解决方案/项目。

  1. Moving pages between folders on the web site.
  2. Source control merging after moving pages can cause pages to be duplicated and Visual Studio gets confused during debugging.
  3. Copy and pasting existing pages (templates) could also cause this from memory.
  1. 在网站上的文件夹之间移动页面。
  2. 移动页面后合并源代码管理可能会导致页面重复,并且 Visual Studio 在调试过程中会变得混乱。
  3. 复制和粘贴现有页面(模板)也可能从内存中导致这种情况。

To resolve the issue I

为了解决这个问题我

  1. Search for "Class TheProblemPageCodeSymbolIssue" for duplicates in the solution.
  2. Re-factored those duplicated code behind class names and tested all those pages, to ensure I could use debug breakpoints.
  1. 在解决方案中搜索“Class TheProblemPageCodeSymbolIssue”以查找重复项。
  2. 重构类名后面的那些重复代码并测试所有这些页面,以确保我可以使用调试断点。

Hope that helps.

希望有帮助。