简体   繁体   English

在 Visual Studio 远程调试中未命中断点

[英]Break point not hit in Visual Studio Remote Debugging

Pls don't mark it as duplicate .. bcoz I have seen all the solutions but nothing is working for my case..请不要将其标记为重复.. bcoz 我已经看到了所有的解决方案,但没有任何解决方案适用于我的情况..

I have two machines devMachine and serverMachine我有两台机器devMachineserverMachine

in devMachine I am developing application with Visual Studio and Now I have a simple Console Application ..my need is I need to run this Console Application in serverMachine and debug from devMachine via Remote Debugging .devMachine 中,我正在使用Visual Studio开发应用程序,现在我有一个简单的控制台应用程序..我需要在serverMachine 中运行此控制台应用程序并通过远程调试devMachine进行调试

As told in Microsoft document, I have installed Remote Debugging tool in serverMachine and set the Authentication mode as Native (No Authentication) and run the Console Application in serverMachine.如 Microsoft 文档中所述,我已在serverMachine 中安装了远程调试工具并将身份验证模式设置为本机(无身份验证)并在 serverMachine 中运行控制台应用程序。

Now , I have attached the remote process in devMachine's Visual Studio.现在,我已经在 devMachine 的 Visual Studio 中附加了远程进程。 All are working fine一切正常

But only problem is breakpoint is not hitting in Visual Studio但唯一的问题是断点在 Visual Studio 中没有命中

Note: I have placed required .pdb file in serverMachine and set that .pdb file path in devMachine's Visual Studio ( Tools->Option->Debugging->Symbols ).注意:我已在serverMachine 中放置了所需的.pdb文件,并在 devMachine 的 Visual Studio 中设置了该.pdb文件路径( Tools->Option->Debugging->Symbols )。

在此处输入图片说明

Can anyone help me to resolve this issue?谁能帮我解决这个问题?

What does the error message on the breakpoints say (if you hover over the breakpoint) - that it's different from the source?断点上的错误消息说明了什么(如果您将鼠标悬停在断点上) - 它与源不同? --> You can try disabling (from Tools/Options/Debugging) - Enable source file to exactly match the original version --> 您可以尝试禁用(从工具/选项/调试) - 启用源文件以与原始版本完全匹配

What does the Modules window say - do the PDB's appear as loaded? “模块”窗口说的是什么 - PDB 是否显示为已加载? if not, have you tried loading them manually (from the Modules window, right click the PDB and load)?如果没有,您是否尝试过手动加载它们(从模块窗口中,右键单击 PDB 并加载)? - Is there an error message if it fails? - 如果失败,是否有错误信息?

--> you might be in a case where the source files in the local machine are different from the ones on the remote one. --> 您可能会遇到本地计算机中的源文件与远程计算机上的源文件不同的情况。 Try copying everything over and see if that works (PDBs would be in the same folder as the EXE)尝试复制所有内容,看看是否有效(PDB 与 EXE 位于同一文件夹中)

There are two reasons for the remote debugger to not hit the breakpoint远程调试器没有命中断点的原因有两个

  1. Wrong symbols.错误的符号。

  2. Using the wrong .Net framework while debugging ( you can select on the "attach to process" window in visual studio).调试时使用错误的 .Net 框架(您可以在 Visual Studio 的“附加到进程”窗口中选择)。

Looking at your screen shot, could it be simply because the break points are in the "main" function which could already have finished before you can attach the debugger?查看您的屏幕截图,是否仅仅是因为断点位于“main”函数中,而该函数在您附加调试器之前可能已经完成?

Suggestion: Maybe put some artificial wait/delay code of say 20 secs in "main" above the first break point to give yourself enough time to attach to the process before "main" completes.建议:也许在第一个断点上方的“main”中放置一些人工等待/延迟代码,例如 20 秒,以便在“main”完成之前给自己足够的时间附加到进程。

Don't attach and just set remote debugging on.不要附加,只需设置远程调试。 Copy all the project files to the identically placed and named folder in the server during post-build.在后期构建期间,将所有项目文件复制到服务器中相同放置和命名的文件夹中。

在此处输入图片说明

在此处输入图片说明

I had an issue with Visual Studio not breaking at my breakpoints although it looked like everything was setup correctly for the remote debugger on an IIS machine.我遇到了 Visual Studio 没有在我的断点处中断的问题,尽管看起来一切都为 IIS 机器上的远程调试器正确设置。 I searched everywhere for an answer.我到处寻找答案。 The issue finally presented itself when I tried to manually attach the VS debug to a process (VS menu --> Debug --> Attach to process...) For some reason, there were multiple processes for the same application pool (there should only be one process, not sure where the others came from) I logged into my IIS server and killed all the processes for my application pool and then restarted the IIS application.当我尝试手动将 VS 调试附加到进程(VS 菜单 --> 调试 --> 附加到进程...)时,问题终于出现了。出于某种原因,同一个应用程序池有多个进程(应该只是一个进程,不确定其他进程来自哪里)我登录到我的 IIS 服务器并杀死了我的应用程序池的所有进程,然后重新启动了 IIS 应用程序。 When I saw there was only one process for the app pool (as I expected), I tried debugging in Visual Studio and it attached to the correct process.当我看到应用程序池只有一个进程时(如我所料),我尝试在 Visual Studio 中进行调试并将其附加到正确的进程。 It turns out that when there were multiple processes for the same application pool, it attached to the "wrong" one.事实证明,当同一个应用程序池有多个进程时,它会附加到“错误”的进程。

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

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