visual-studio Visual Studio 不会调试到引用的 DLL(来自相同的解决方案)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2539273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual studio won't debug into referenced DLL (from same solution)
提问by Greg
I have a Visual studio 2008 solution, with 2 projects. A DLL, A, and a Web application, B.
我有一个 Visual Studio 2008 解决方案,有 2 个项目。一个 DLL A 和一个 Web 应用程序 B。
B has a project reference to A, and A.dll and A.pdb are being copied to B's bin/ directory.
B 有一个对 A 的项目引用,并且 A.dll 和 A.pdb 正在被复制到 B 的 bin/ 目录。
Everything is set to compile in debug mode.
一切都设置为在调试模式下编译。
I can run the cassini webserver and debug web application B fine, but when I come to call a method in A.dll, pressing F11 to step into it does not step into it, it steps over it. I want to step into it.
我可以很好地运行cassini webserver并调试web应用程序B,但是当我在A.dll中调用一个方法时,按F11进入它并没有进入它,它跳过它。我想进入它。
Any ideas why I might not be able to step into the source code of A?
为什么我可能无法进入 A 的源代码的任何想法?
Edit: Additional Info
编辑:附加信息
I do not have 'just my code' checked.
我没有检查“只是我的代码”。
I can set a breakpoint in the DLL, and it shows as a red circle (not a hollow one), but it is never hit.
我可以在 DLL 中设置一个断点,它显示为一个红色圆圈(不是空心圆圈),但它从未被击中。
Hmmm... I just altered the code in the DLL which is being called to start with
嗯...我只是更改了正在调用的 DLL 中的代码以开始
throw new Exception("Hello");
And I'm not getting an exception. That's pretty suspicious...
而且我没有例外。实在是太可疑了……
采纳答案by Greg
Aha!
啊哈!
The method in B I was calling returned IEnumerator<SomeObject>. It was an iterator block with yield keywords and so was not being executed (as I hadn't written the consumer yet).
BI 中的方法调用了返回IEnumerator<SomeObject>。它是一个带有 yield 关键字的迭代器块,因此没有被执行(因为我还没有编写消费者)。
sigh
叹
回答by JaredPar
The most likely problem is that Visual Studio doesn't consider the DLL to be part of "your code". The way to work around this is to disable the "Just My Code" debugging feature.
最可能的问题是 Visual Studio 不认为 DLL 是“您的代码”的一部分。解决此问题的方法是禁用“仅我的代码”调试功能。
- Tools -> Options -> Debugging
- Uncheck "Enable Just My Code"
- 工具 -> 选项 -> 调试
- 取消选中“仅启用我的代码”
After doing this you should be able to step into your code without incident.
完成此操作后,您应该能够顺利进入您的代码。
回答by jKlaus
To those saying to disable "Just My Code", he specifically states the two projects are in the same solution so that would not apply. The only logical conclusion is user error/misunderstanding.
对于那些说要禁用“仅我的代码”的人,他特别指出这两个项目在同一个解决方案中,因此不适用。唯一合乎逻辑的结论是用户错误/误解。
回答by Matt Brunell
You probably have the 'Just my code' option set in your debugging options. Turn that off and you can step into code from a dll.
您可能在调试选项中设置了“仅我的代码”选项。关闭它,您就可以从 dll 进入代码。
回答by Phil Haselden
Check whether the DLL has a line like the following in its AssemblyInfo.cs. You may have to temporarily comment out that line in order to step into the DLL while debugging.
检查 DLL 在它的 AssemblyInfo.cs 中是否有如下一行。您可能需要暂时注释掉该行,以便在调试时进入 DLL。
[assembly: AssemblyKeyFile("..\..\something.snk")]

