为什么 VS2010 调试器没有在我的断点处停止?

发布于 2024-09-15 20:02:37 字数 263 浏览 12 评论 0原文

我正在 VS2010 中开发一个 C#.NET 类库项目。在我的项目设置->调试设置中,我将项目设置为启动外部程序(C:\Windows\SysWOW64\wscript.exe),该程序运行一个非常简单的 jscript 文件(test.js)。该脚本只是创建该类的一个实例并调用它的方法之一。

问题是当我开始调试时,VS2010 不会在我的任何断点处停止。如果我在 VS2008 中打开完全相同的项目,它确实会在断点处停止。是否有新的设置可以防止断点被击中?还有其他人遇到过这个问题吗?

I am working on a C#.NET class library project in VS2010. In my project settings -> debug settings, I have the project set to start an external program (C:\Windows\SysWOW64\wscript.exe) which runs a very simple jscript file (test.js). The script simply creates an instance of the class and calls one of it's methods.

The problem is when I start debugging, VS2010 does not stop at any of my breakpoints. If I open up the exact same project in VS2008 it does stop at the break points. Is there a new setting somewhere that is preventing the breakpoints from being hit? Has anyone else ran into this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

乜一 2024-09-22 20:02:37

要解决此问题,请为使用该组件使用以下数据进行调试的应用程序创建一个配置文件:

<?xml version="1.0"?>
<configuration>
  <startup>
     <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

使用此文件,您可以告诉调试器使用正确的运行时版本进行调试(调试器默认使用版本 4.0) 。

To solved this problem by creating a config file for the application which is using the component to debug with the following data:

<?xml version="1.0"?>
<configuration>
  <startup>
     <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

With this file you tell the debugger to use the right runtime version for debugging (it seems the debugger uses version 4.0 by default).

来日方长 2024-09-22 20:02:37

我的第一个检查是禁用“Just My Code”

  • 工具 ->选项
  • 调试器
  • 取消选中“仅启用我的代码”

再次尝试该场景。

My first check would be to disable "Just My Code"

  • Tools -> Options
  • Debugger
  • Uncheck "Enable Just My Code"

Try the scenario again.

安人多梦 2024-09-22 20:02:37

我尝试了一整天来找出为什么我无法调试我的 Visual Studio 2012 控制台应用程序,答案很尴尬。

我在“RELEASE”模式下运行它。

有时,显而易见的东西却很难找到。

I have a tried a whole day to find out why I couldn't debug my visual studio 2012 console application, and the answer was embarrassing.

I was running it in "RELEASE" mode.

Sometimes the obvious is the hard to find.

悲歌长辞 2024-09-22 20:02:37

我有一个“重建”的 VS2013 项目,我无法调试(没有符号)。最后,我看到优化被选中(项目->属性->构建)。我取消选中它并重建。符号终于加载了。我的两分钱,仅在绝对必要时才使用(编译)优化。

I had a "Rebuilt" VS2013 project that I couldn't debug (no symbols). Finally, I saw Optimization was checked (Project->Properties->Build). I unchecked it and Rebuilt. Symbols loaded finally. My two cents, only use (compile) Optimization when absolutely necessary.

寻找我们的幸福 2024-09-22 20:02:37

关闭 Visual Studio IDE 并打开它。现在它就可以工作了。我也面临同样的问题。我用这种方式克服了

Close the Visual Studio IDE and Open it. Now it will work. I also face the same issue. I used this way to overcome

一绘本一梦想 2024-09-22 20:02:37

虽然我无法回答为什么会发生这种情况,但我可以为您提供解决方法。

  1. 包括

    使用 System.Diagnostics;
    
  2. 在代码的最开头(例如类构造函数)放置以下几行:

    #if (调试)
                    while(!Debugger.IsAttached);
                    调试器.Break();
    #endif
    
  3. 开始调试。

  4. 菜单工具→附加到流程
  5. 附加到您的流程。

断点应该在您的代码中触发。
其他断点也应该触发。

While I can't answer why it happens, I can provide you with workaround.

  1. Include

    using System.Diagnostics;
    
  2. At the very beginning of your code (Class constructor for instance) place the following lines:

    #if (DEBUG)
                    while(!Debugger.IsAttached);
                    Debugger.Break();
    #endif
    
  3. Start debugging.

  4. Menu Tools→Attach to Process
  5. Attach to your process.

breakpoint should trigger in your code.
Other breakpoints should trigger as well.

带刺的爱情 2024-09-22 20:02:37

可能有很多原因。通常这是因为您尝试针对错误的版本进行调试。

这些动作大约在 80% 的情况下有效。

  • 获取最新代码
  • Clean
  • Rebuild
  • 重启 IIS
  • 再试一下

如果不行,进入 Debug >窗口>模块,如果相关的 dll 存在,右键单击它并加载符号。

如果它不在列表中,请尝试运行该代码。有时,即使它说不会命中断点,但这只是因为在您进入需要它的场景之前,该 dll 尚未加载。尝试一下依赖于 dll 的场景,无论如何它都可能会遇到断点。

哦,还有一个想法,重新启动浏览器。您可能缓存了旧 dll 中的某些内容。

Could be a number of reasons. Usually it's because you're trying to debug against the wrong version.

These actions work about 80% of the time.

  • Get the latest code
  • Clean
  • Rebuild
  • Restart IIS
  • Try again

If no good, go to Debug > Windows > Modules and if the relevant dll is there, right click it and load symbols.

If it's not in the list, try running the code anyway. Sometimes even though it says the breakpoint will not be hit, it's only because the dll is not loaded until you enter a scenario that needs it. Try the scenario that depends on the dll, and it may just hit the breakpoint anyway.

Oh one more idea, restart your browser. You might have something cached from an older dll.

遗失的美好 2024-09-22 20:02:37

如果原因是 .NET 运行时版本错误(这是我的问题),您只需在附加到进程对话框中选择正确的版本即可,而不是创建配置文件。

在对话框中,点击附加到旁边的选择并从自动切换。 ..调试这些代码类型,您应该在其中检查正确的版本。

如果这也是您的问题,那么您的断点上可能会出现“符号未加载”消息。选择正确的版本后,您应该会立即看到不再报告此错误。

If the reason is wrong .NET runtime version (which was my problem), instead of creating configuration file you can simply choose the right version in the Attach to process dialog.

In the dialog, next to Attach to click on Select and switch from Automatically... to Debug these code types where you should check the right version.

If this was your problem also, then you probably had "Symbols not loaded" message on your breakpoints. Immediately after selecting the right version you should see that this error is no longer reported.

老街孤人 2024-09-22 20:02:37

对我来说,它是通过以下方式修复的:

  1. 打开项目属性是 VS2010

  2. Goto Compile ->高级编译选项

  3. 将“生成调试信息”从“无”更改为“完整”

For me it was fixed by:

  1. Open the project properties is VS2010

  2. Goto Compile -> Advanced Compile Options

  3. Change 'Generate debug Info' from 'None' to 'Full'

顾冷 2024-09-22 20:02:37

问题可能是您的浏览器正在使用您正在使用的页面的缓存版本。
尝试在浏览器的地址行中添加一些无意义的额外查询字符串 fx add ?NONSENSE=1234
这迫使浏览器使用新版本的网页,因为它不知道该页面最终是否应该与此查询不同。下次使用 ?NONSENS=1235。

The problem could be your browser is using a cached version of the page, you are working with.
Try to add som nonsense extra querystring in your adress line of the browser f.x. add ?NONSENSE=1234
This forces the browser to use a new version of the web page since it does not know if the page should look different with this Query in the end. Next time use ?NONSENS=1235.

那些过往 2024-09-22 20:02:37

我的本机 C++ 代码中存在断点放错位置的问题。
原因是我一直在编辑代码,因此代码中的某些行结尾不是 \r\n。除非您搜索 \r\n,否则无法在代码中看到。
插入正确的行结束 \r\n 后,调试器开始工作。

I had a problem with misplaced breakpoints in my native c++ code.
The reason was I had been editing the code so some line ends in the code was not \r\n. It was not possible to see in the code unless you searched for \r\n.
After inserting the proper line ends \r\n the debugger worked.

过去的过去 2024-09-22 20:02:37

我遇到了类似的问题,但它是在 CLR 项目中。我在 CLR 项目中有一些旧的 C++ 语法。对我来说,在“工具”>“选项”>“调试”>“常规”中启用“使用托管兼容性模式”后,它开始遇到断点。

I encountered the similar issue but its in a CLR project. I had some old c++ syntax in the CLR project. For me after I enabled 'Use managed compatibility mode' in Tools>options>Debugging>General it started to hit the break points.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文