Visual Studio 调试器 - 是我一个人的问题还是这个调试器本身充满了错误?

发布于 2024-12-11 11:34:46 字数 537 浏览 5 评论 0原文

我开始对 Visual Web Developer Express 调试感到非常沮丧。

编辑 - 这主要是关于调试 C#

似乎我经常设置两个或三个断点。所发生的情况是光标最终会循环。我将完成所有断点,但光标不会退出调试并向我显示浏览器中网页的结果,而是跳回到开头。

或者,我将到达断点的一半,光标将跳回到前一个断点,并陷入循环,再次总是跳回到前一个断点。

调试器似乎不一致,有时它可以正常工作,有时它会如上所述。

有时,当发生这种情况时,我会看到一个黄色箭头,其边缘有一个小蓝点。当我将鼠标悬停在它上面时,它会显示“自上一步以来进程或线程已更改”,这是什么意思?

我也得到了不准确的异常。我有一个 C# 方法,它采用 out 参数。当光标到达此方法调用时,有时它会给我一个空引用异常。但它是一个 out 参数,它们允许为空。 VWD 似乎又不一致。有时我会遇到这个问题,但大多数时候我不会。

是我做错了什么还是 VWD 调试器有很多螺丝松动了?

请帮助我,因为我开始运用我的思想!

I am starting to get really frustrated with the Visual Web Developer Express Debugging.

edit - This is mostly regarding debugging C#

It seem often I set two or three break points. And what happens is the cursor ends up going around in a loop. I will have been through all of my breakpoints but instead of exiting the debugging and showing me the result of the web page in the browser the cursor jumps back to the beginning.

Or I will be half way through my break points and the cursor will jump back to the previous breakpoint and and get stuck in a loop, again always jumping back to the previous break point.

It seems the debugger is not consistent either sometimes it will work fine and other times it will do as described above.

Sometimes I get a yellow arrow with a tiny blue dot in the margin when this is happening. Which when I hover over it says "The process or thread has changed since the last step" what is that all about?

Also I am getting inacurate Exceptions. I have a method in C# that takes an out parameter. When the cursor reaches this method call sometimes it gives me a null reference exception. But it is an out parameter they are allowed to be null. And again VWD seems to be inconsistent. Sometimes I get this problem, most of the time I don't.

Am I doing something wrong or has VWD Debugger got a lot of screws loose?

Please help me because I am starting to use my mind!

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

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

发布评论

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

评论(2

初懵 2024-12-18 11:34:46

我怀疑您有许多线程在同一代码中同时运行。 当您设置断点时,该断点适用于所有线程,而不仅仅是您创建断点时正在运行的线程。如果您点击“go”并且另一个线程开始运行,并且它首先到达断点,那么这就是您现在正在调试的线程。这可能会非常令人困惑。

当我处于这种情况时我会做什么 - 相信我,我每天都处于这种情况 - 我养成了总是冻结除我真正想要的线程之外的每个线程的习惯进行调试。这样,当我调试程序时,该程序实际上是单线程的。只是不要忘记将它们解冻!

My suspicion is that you have many threads running concurrently in the same code. When you put a breakpoint down, that breakpoint applies to all the threads, not just the one that was running when you made it. If you hit "go" and another thread starts running, and it hits the breakpoint first, that's the thread that you're now debugging. It can be very confusing.

What I do when I'm in that scenario -- and I am in that scenario every single day, believe me -- I get in the habit of always freezing every thread but the one I am actually wanting to debug. That way the program is effectively single-threaded while I am debugging it. Just don't forget to thaw them out!

ま柒月 2024-12-18 11:34:46

这很可能是您或您的代码所特有的东西。

在过去的 18 个月里,我一直在频繁使用 Visual Studio 2010 的调试器。在此之前,我一直使用 Visual Studio 的 C# 调试器,一直到最初的 Visual Studio .Net 版本。我从未发现任何重大错误。大多数时候我以为我发现了一个错误,但实际上我的理解或我的代码存在缺陷。

花时间了解正在发生的情况、图标和指示器的含义以及如何操作调试器,您很可能会发现:

  1. VWD 工作正常。
  2. 你的代码不是。
  3. 对编程有更深入的了解。

作为一种思维习惯,我鼓励您研究“选择不会被破坏”。

以下是让我认为您缺乏理解的具体事项:

  1. 您说“当光标到达此方法调用时...”这是描述情况的错误措辞。当光标进入或越过方法调用时,将调用该方法。如果光标仅位于方法调用上,则该方法尚未执行。
  2. 你怎么知道 out 参数给你带来了麻烦?如果你调用一个对象的方法,也许你对该对象的引用是空的?
  3. 不一致的调试器行为实际上可以是(由调试器)不一致的程序代码的一致报告。
  4. 您在第二段和第三段中的措辞和描述不精确,对于没有看到您的具体调试设置的人没有帮助。

简而言之,是的,你确实感觉自己失去了理智。我表示同情。这种感觉永远不会消失,但这种不适意味着你的大脑正在变大。继续尝试,但您有必要了解更多有关调试器如何工作的信息。花更多时间单步执行可以正常工作的代码。

编辑:
您没有提及如何逐步执行代码。只是断点被击中(按照您不同意的顺序)。了解 VWD 中的步入、步过、步出和运行到光标命令。因为您将其作为网站的一部分运行,所以这些可能还不够。您可能正在为同时发生的请求提供服务而没有意识到。当断点被命中时,这将导致执行在线程之间以看似随机的顺序交替执行。确保您一次只处理一个请求,或者至少注意您的线程 ID。

It is most likely something peculiar to you or your code.

I've been using Visual Studio 2010's debugger frequently for the last 18 months. Before that, I consistently used Visual Studio's C# debugger all the way back to the original Visual Studio .Net release. I have never found any major bugs. Most times I thought I found a bug, there was actually a flaw in my understanding, or my code.

Take the time to understand what is happening, and what the icons and indicators mean, and how to operate the debugger and you will most likely find:

  1. VWD is working correctly.
  2. Your code isn't.
  3. A greater understanding of programming.

As a habit of mind, I would encourage you to research "select isn't broken".

Here are the specific things that make me think that your understanding is lacking:

  1. You say "when the cursor reaches this method call..." This is incorrect phrasing to describe the situation. The method is invoked when the cursor steps into or over the method call. If the cursor is only on the method call, that method hasn't executed yet.
  2. How do you know the out parameter is giving you the trouble? If you are invoking the method on an object, perhaps your reference to the object is null?
  3. Inconsistent debugger behavior can actually be consistent reporting (by the debugger) of inconsistent program code.
  4. Your phrasing and description in the second and third paragraphs is imprecise, and not helpful to anyone who hasn't seen your specific debugging setup.

In short, yes, you do feel like you're losing your mind. I sympathize. That feeling never goes away, but the discomfort means your brain is getting bigger. Keep trying, but it would behoove you to learn more about how a debugger works. Spend more time stepping through code that does work properly.

Edit:
You don't mention how you step through the code. Only that the breakpoints are being hit (in an order you don't agree with). Learn about the step-in, step-over, step-out and run-to-cursor commands in VWD. Because you're running this as part of a website, those may not be enough. You may be servicing simultaneous requests without realizing it. This will cause execution to alternate between threads in a seemingly random sequence as the breakpoints are hit. Make sure you're only serving one request at a time, or at least pay attention to your thread ids.

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