启用和禁用“步入” 在 Visual Studio 解决方案中调试某些项目

发布于 2024-07-07 06:24:15 字数 478 浏览 9 评论 0原文

我有一个 Visual Studio 解决方案,其中包含四个 C# 项目。 我想从我的主项目中单步进入解决方案中支持项目的代码,但是当我使用“单步进入”键时,它只是跳过对其他项目的调用。 我在支持项目中设置了断点,但它们被忽略了,而且我一生都无法让它进入对该项目的任何引用。

一切都设置为编译为“调试”,并且我看到 Visual Studio 警告我之前不会命中我的断点 - 在这种情况下它不会这样做。 就好像我的代码可以进行调试,但在运行时,有一个设置告诉 Visual Studio 不要单步执行该项目中的代码。 我的解决方案中的所有其他项目调试都没有问题。

我选中了什么框导致了这种行为?

更新清晰:“仅我的代码”选项当前已禁用。 另外,由于代码属于我的同一解决方案中的项目,因此我认为“仅我的代码”选项不适用于此处。 我认为它仅适用于我没有源代码的预编译代码,但由于我的项目中有源代码,所以我认为此选项没有任何效果。

I have a Visual Studio solution with four C# projects in it. I want to step into the code of a supporting project in the solution from my main project, but when I use the "Step into" key, it just skips over the call into that other project. I've set breakpoints in the supporting project, and they're ignored, and I can't for the life of me get it to step into any references to that project.

Everything is set to compile as "Debug", and I've seen Visual Studio warn me that my breakpoints won't be hit before - it doesn't do that in this case. It's as though it looks as though my code will debug, but then at run-time, there's a setting somewhere that tells Visual Studio not to step through the code in that project. All the other projects in my solutions debug without problems.

What box have I checked to cause this behavior?

UPDATE FOR CLARITY: The "Just my code" option is currently disabled. Also, since the code belongs to a project in my same solution, I don't think the "Just my code" option applies here. I thought it only applied to pre-compiled code that I didn't have the source for, but since I have the source in my project, I don't think this option has any effect.

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

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

发布评论

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

评论(7

哭了丶谁疼 2024-07-14 06:24:16

要检查的一件事是您的支持项目程序集尚未安装在 GAC 中。 打开命令提示符并运行以下命令以确保...

gacutil /l 程序集名称

One thing to check for is that your supporting project assembly has not been installed in the GAC. Open a command prompt and run the following to make sure...

gacutil /l assemblyName

好倦 2024-07-14 06:24:16

您需要确保支持项目具有 pdb 文件,否则 Visual Studio 将没有必要的信息来逐步执行代码。

You need to ensure the supporting projects have pdb files or else Visual Studio will not have the necessary information to step through the code.

剩一世无双 2024-07-14 06:24:16

如果您有要尝试进入的 dll 的源代码,请执行以下操作:

  1. 单击将这些 dll 添加为引用的项目并将其删除。
  2. 将与 dll 对应的项目添加到解决方案中
  3. 右键单击项目 -> 添加参考-> 选择新添加的项目。

现在设置断点并调试代码。您将能够单步执行代码。

出现此问题的原因是您的程序仍在引用旧的 dll(没有源代码),因为它已作为引用添加到您的项目中。 一旦您删除该 dll 并添加该 dll 的项目(dll 的源代码),Visual studio 将能够单步执行您的代码。

If you have the source code for the dll's into which you are trying to step into, do the following:

  1. Click on the project in which these dll's are added as reference and remove them.
  2. Add the Project(s) corresponding to the dll(s) to the solution
  3. Right click on the project -> Add Reference -> Choose the newly added Project(s).

Now set the break point and debug the code.. You will be able to step into the code.

The reason for the issue is because you program is still referencing the old dll (without the source code) as it has been added to your project as a reference. Once you remove that dll and add the Project (Source code of the dll) of the dll, Visual studio will be able to step into your code.

听不够的曲调 2024-07-14 06:24:16

几种可能性:

  • 有一个复选框可以进入“仅我的代码”。 其目的是让您无法进入 Microsoft 的框架代码(除非您通过取消选中该框来选择进入)。

  • 您可以尝试重新编译支持代码,以确保您正在调试的代码与您正在查看的代码文件完全匹配。 VS确实关心这一点,如果你把它放在版本不匹配的代码文件中,它会禁用断点。 另外,请确保 PDB 文件与 DLL 位于同一目录中。

A couple of possibilities:

  • There is a check box to step into "just my code". Its intent is to make it so you can't step into Microsoft's Framework code (unless you choose to by unchecking the box).

  • You might try recompiling the supporting code to make sure the code you're debugging exactly matches the code file you're looking at. VS does care about this and will disable a breakpoint if you put it in the code file whose version doesn't match. Also, make sure the PDB file is in the same directory as the DLL.

束缚m 2024-07-14 06:24:16

在 Visual Studio 2013 中,导致此行为的一种方法是将生成配置设置为 Release
将其放回调试并查看是否有帮助。

在此处输入图像描述

In Visual Studio 2013 one way to cause this behaviour is to set build configuration to Release.
Put it back to Debug and see if that helps.

enter image description here

泛滥成性 2024-07-14 06:24:15

不确定是否是这样,但“工具>选项>调试>常规:仅启用我的代码”是可能的。 (我更喜欢始终不检查此选项。)

Not sure if this is it, but "Tools>Options>Debugging>General:Enable Just My Code" is a possibility. (I prefer to always leave this unchecked.)

伤痕我心 2024-07-14 06:24:15

事实证明,需要将程序集复制到 GAC 中才能进行调试。 在调试选项“仅我的代码”下,如果您没有任何用户代码,则有一个选项可以抑制错误,并且它会抑制以下错误:

以下手机是构建的
启用或不启用优化
调试信息。 (模块名称和
路径)要调试此模块,请更改其
将配置构建为调试模式。

由于我是在调试配置中构建它的,所以我搜索了该错误消息并得到了以下内容:

http://claytonj.wordpress.com/2008/01/04/the-following-module-was-built-either -with-optimizations-enabled-or-without-debug-information/

问题已解决。 我不知道为什么它需要在 GAC 中才能让我参与该项目,但确实如此。 我不问为什么,我只问如何,然后我就这么做……

It turns out that the assembly needed to be copied into the GAC before it could be debugged. Under the debugging option "Just my code", there's an option to suppress an error if you don't have any user code, and it was suppressing the following error:

The Following mobile was built either
with optimizations enabled or without
debug information. (Module name and
path) To debug this module, change its
build configuration to Debug mode.

Since I was building it in Debug configuration, I searched on that error message and got this:

http://claytonj.wordpress.com/2008/01/04/the-following-module-was-built-either-with-optimizations-enabled-or-without-debug-information/

Problem solved. I don't know why it needs to be in the GAC in order for me to step into the project, but it does. I don't ask why, I just ask how, and then I do it...

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