[英]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:我按照以下步骤调试服务:
installutil /u TransactionalMessaging.exe
in the Debug folderinstallutil /u TransactionalMessaging.exe
通过 VS 命令行卸载 Transactional Messaging Serviceinstallutil TransactionalMessaging.exe
in the Debug folderinstallutil TransactionalMessaging.exe
通过 VS 命令行安装事务性消息服务 Steps I've tried to solve this error:我尝试解决此错误的步骤:
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.