简体   繁体   English

C# Visual Studio 服务调试“当前不会命中断点。没有为此文档加载任何符号”

[英]C# Visual Studio Service Debugging "The breakpoint will not currently be hit. No Symbols have been loaded for this document"

New to Visual Studio and new to C#. Visual Studio 的新手和 C# 的新手。 Building a C# windows service called Transactional Messaging in Visual Studio 2017, which is dependent on a project called Outbound Messaging.在 Visual Studio 2017 中构建一个名为 Transactional Messaging 的 C# windows 服务,它依赖于一个名为 Outbound Messaging 的项目。 When I start debugging and try adding breakpoints on the Outbound Messaging files, I get当我开始调试并尝试在出站消息文件上添加断点时,我得到

"The breakpoint will not currently be hit. No Symbols have been loaded for this document" “当前不会命中断点。没有为该文档加载任何符号”

From what I can tell, VS is only unable to load the pdb files for: log4net.dll, Castle.Windsor.dll, and Castle.Core.dll.据我所知,VS 仅无法加载以下 pdb 文件:log4net.dll、Castle.Windsor.dll 和 Castle.Core.dll。 I don't have this issue with adding breakpoints to files in the Transactional Messaging Service.我没有向事务消息服务中的文件添加断点的问题。 I haven't been able to identify behavior patterns or a permanent fix, so at this point the error seems random.我无法识别行为模式或永久修复,所以此时错误似乎是随机的。 One minute I think I've found a fix, and when I try using that fix on the same error later in the day I have no luck.前一分钟我认为我找到了一个修复程序,但当我在当天晚些时候尝试使用该修复程序解决同一个错误时,我没有运气。 I am suspicious of a recent power outage that shut my computer down unexpectedly since it looks like pdb files can be cached, but have been told that would be a long shot.我怀疑最近的一次停电导致我的计算机意外关闭,因为它看起来可以缓存 pdb 文件,但有人告诉我这不太可能。

Steps I follow to debug the service:我按照以下步骤调试服务:

  1. Stop Transactional Messaging Service via windows services applet通过 Windows 服务小程序停止事务性消息服务
  2. Uninstall Transactional Messaging Service via VS command line using installutil /u TransactionalMessaging.exe in the Debug folder使用 Debug 文件夹中的installutil /u TransactionalMessaging.exe通过 VS 命令行卸载 Transactional Messaging Service
  3. Clean Transactional Messaging Solution in Visual Studio Visual Studio 中的清洁事务消息传递解决方案
  4. Build Transactional Messaging Solution in Visual Studio (at one point a fix was to right click on each aspect of the solution in the solution explorer and build that individually)在 Visual Studio 中构建事务性消息传递解决方案(有一次修复是在解决方案资源管理器中右键单击解决方案的各个方面并单独构建)
  5. Install the Transactional Messaging Service via VS command line using installutil TransactionalMessaging.exe in the Debug folder使用 Debug 文件夹中的installutil TransactionalMessaging.exe通过 VS 命令行安装事务性消息服务
  6. Start the Transactional Messaging Service via windows service applet通过 Windows 服务小程序启动 Transactional Messaging Service
  7. In VS, Debug > attach to process > Transactional Messaging在 VS 中,调试 > 附加到进程 > 事务性消息传递
  8. Try adding breakpoints to files in Outbound Messaging service which gets me the above error.尝试向出站消息服务中的文件添加断点,这让我出现了上述错误。

Steps I've tried to solve this error:我尝试解决此错误的步骤:

  1. Debug > Windows > Modules to manually load each module's symbols (pdb files for log4net.dll, Castle.Windsor.dll, and Castle.Core.dll cannot be found) picture of modules Debug > Windows > Modules 手动加载每个模块的符号(无法找到 log4net.dll、Castle.Windsor.dll 和 Castle.Core.dll 的 pdb 文件)模块图片
  2. Completely delete bin and obj folder between steps 2 and 3 above在上面的步骤 2 和 3 之间完全删除 bin 和 obj 文件夹
  3. Project > Project properties > Build > Advanced > Debugging Information: full (for both Transactional Messaging and Outbound Messaging) Project > Project properties > Build > Advanced > Debugging Information:完整(用于事务性消息传递和出站消息传递)

I'm not sure if this is a lack of understanding of VS, C#, or the code base.我不确定这是否是对 VS、C# 或代码库缺乏了解。 Any insight is appreciated, I'm past the googling stage and posting a new question as a last resort.任何见解表示赞赏,我已经过了谷歌搜索阶段并发布了一个新问题作为最后的手段。

I usually get this message when I have changed code in a project A and forgot to compile it.当我更改项目 A 中的代码并忘记编译它时,我通常会收到此消息。
The other project B, which references project A, has the up-to-date source code of A on the screen, but started with an outdated assembly of A. So it cannot enable breakpoints because the code does not match the assembly.引用项目 A 的另一个项目 B 在屏幕上显示了 A 的最新源代码,但以 A 的过时程序集启动。因此它无法启用断点,因为代码与程序集不匹配。

There's one more thing, which in my opinion is a bug and a pain in the ass, but according to MS is by design (I have asked them):还有一件事,在我看来这是一个错误和麻烦,但根据 MS 的说法是设计使然(我问过他们):
Since Visual Studio 2015, the compilation of project B does NOT automatically include modified referenced assemblies, which in this example is assembly A. There is a local copy of A somewhere in B, which is used instead.自 Visual Studio 2015 起,项目 B 的编译不会自动包含修改后的引用程序集,在此示例中为程序集 A。B 中某处存在 A 的本地副本,而是使用该副本。 Same result as above: up-to-date code, but outdated assembly.与上面相同的结果:最新的代码,但过时的程序集。 Instead of compiling, you have to rebuild it!而不是编译,你必须重建它!

There's another one more thing:还有一件事:
You have to compile for DEBUG mode.您必须针对 DEBUG 模式进行编译。 In Release mode, the default project settings do not allow proper debugging, like they did in VS 2008 for example.在发布模式下,默认项目设置不允许正确调试,例如在 VS 2008 中。

You can not attach the debugger, because you are lacking the right to do so.您不能附加调试器,因为您没有这样做的权利。 You can get this right only be flipping a certain bit in the registry.您只需翻转注册表中的某个位即可获得此权利。

See my earlier Answer:看我之前的回答:

Also start VisualStudio as Administrator and allow, that a process can automatically be debugged by a different user:同时以管理员身份启动 VisualStudio 并允许不同用户自动调试进程:

 reg add "HKCR\AppID\{E62A7A31-6025-408E-87F6-81AEB0DC9347}" /v AppIDFlags /t REG_DWORD /d 8 /f

If nothing help from above than make sure your files are open from the relevant project, not from another (old) one.如果上面没有任何帮助,请确保您的文件是从相关项目中打开的,而不是从另一个(旧的)项目中打开的。

Example:例子:

  • You working on a project, close the VS, but you left files (tabs) open in VS.你在一个项目上工作,关闭了 VS,但你在 VS 中打开了文件(选项卡)。

  • Copy your project to a new folder and open solution.将您的项目复制到一个新文件夹并打开解决方案。 The files (tabs) will load from the old directory and if you want to debug then you cannot debug until you close them and reload them from the current folder.文件(选项卡)将从旧目录加载,如果你想调试,那么你无法调试,直到你关闭它们并从当前文件夹重新加载它们。

I was very close to reinstall my VS because nothing helped for me from another answers, but fortunately I realised this in my project and I can debug now.我非常接近重新安装我的 VS,因为其他答案对我没有任何帮助,但幸运的是我在我的项目中意识到了这一点,我现在可以调试了。

暂无
暂无

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

相关问题 当前不会命中断点。 未在 Unity 中为该文档加载任何符号 - The breakpoint will not currently be hit. No symbols have been loaded for this document in Unity VS-2012 :当前不会命中断点。 尚未为该文档加载任何符号 - VS-2012 : Breakpoint will not currently be hit. No symbols have been loaded for this document 附加调试器 - 当前不会触发断点。 没有为此文档加载任何符号 - Attach Debugger - The breakpoint will not be currently hit. No symbols have been loaded for this document 断点当前不会被击中。在Silverlight应用程序中没有为此文档加载任何符号 - The breakpoint will not currently be hit. No symbols have been loaded for this document in a Silverlight application VS 2010,NUNit和“断点目前不会被击中。 没有为此文档加载任何符号“ - VS 2010, NUNit, and “The breakpoint will not currently be hit. No symbols have been loaded for this document” VS2015 目前不会命中断点。 没有为此文档加载任何符号 - VS2015 The breakpoint will not currently be hit. No symbols have been loaded for this document VS 2013断点目前不会被击中。 没有为此文档加载任何符号 - VS 2013 the breakpoint will not currently be hit. no symbols have been loaded for this document 断点当前不会被命中。 没有为该文档加载任何符号。 删除dll时 - The breakpoint will not currently be hit. No symbols have been loaded for this document. when debussing dll 此断点当前不会被命中。 在项目 asp.net web forms 中没有为此文档加载任何符号 - this breakpoint will not currently be hit. no symbols have been loaded for this document in project asp.net web forms 如何补救“当前不会命中断点。没有为该文档加载任何符号。” 警告? - How do I remedy "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM