Visual Studio - 一些断点没有中断
我在 Visual Studio 2010 中有一个包含 9 个项目的解决方案,这些项目受 Source Safe 的源代码控制。我最近刚刚刷了硬盘并从 WinXP x86 升级到 Win7 x64(早就该了!)。当我检查“新”机器的解决方案时,某些部分现在无法正常工作,因此我正在尝试对其进行调试。
也许值得注意的是,我之前是在VS2008中工作的。当我升级时,我首先在 VS2008 中打开该项目以确保它正常工作,我注意到有一些问题需要调试。我设置了一些断点,有几个断点有效,有几个断点没有。我无法立即弄清楚为什么有些没有崩溃,所以我决定继续将项目升级到 VS2010,希望它能自行解决。事实并非如此。
主项目调用项目中公共模块中的公共子项目,该项目是每个其他项目引用的库。我在主窗体 Form_Load 上有一个断点,一旦代码开始运行,它就会成功中断。 Form_Load 调用前面提到的公共子程序,该子程序也有一个断点。但该断点不会中断。换句话说,调试器将在调用 ProjectStartupActions()
处停止,但不会在定义 Public Sub ProjectStartupActions()
或其中的任何行处停止。
如果我在 Form_Load 中的子调用上“转到定义”,它会跳转到我有断点的正确位置,因此我确信我已经正确放置了断点。
我的项目>>调试>>所有项目的配置设置为“活动(调试)”,平台设置为“活动(任何 CPU)”。为了进一步确认它应该在调试而不是发布中运行,如果我打开资源管理器窗口到库项目的“调试”文件夹并清理该项目,该文件夹就会清空。当我重建或运行时,文件全部被替换。
感谢您的任何帮助。
哦,是的,我还对 Public Sub ProjectStartupActions()
的代码进行了更改。我将 MsgBox("Hello")
添加到子文件的第一行,但它从未弹出。
I have a solution in Visual Studio 2010 with 9 projects which is under source control with Source Safe. I just recently swiped my hard-drive and upgraded to Win7 x64 from WinXP x86 (long overdue!). When I checked the solution out to the "new" machine, some parts are not working correctly now, so I'm trying to debug it.
Perhaps worth noting is that I was working in VS2008 before. When I upgraded, I first opened the project in VS2008 to make sure it worked and I noticed there were problems that I needed to debug. I set some breakpoints and a couple worked and a couple didn't. I couldn't immediately figure out why some weren't breaking, so I decided to go ahead and upgrade the project to VS2010 hoping it would work itself out. It didn't.
The main project calls a public sub in a public module in a project that is a library referenced by every other project. I have a breakpoint on the main form Form_Load which breaks successfully as soon as the code begins running. The Form_Load calls the aforementioned public sub which also has a breakpoint. But that breakpoint DOES NOT break. In other words, the debugger will stop on the call ProjectStartupActions()
but will not stop on the definition Public Sub ProjectStartupActions()
or any line in it.
If I "Go To Definition" on the sub call in Form_Load, it jumps to the correct place where I have the breakpoint, so I'm certain I've placed the breakpoint correctly.
My Project >> Debug >> Configuration is set to "Active (Debug)" and Platform is "Active (Any CPU)" for all projects. To further confirm that it should be running in Debug rather than Release, if I open an explorer window to the "Debug" folder for the library project and clean the project, the folder empties out. When I rebuild or run the files are all replaced.
Thanks for any help.
Oh yeah, also I made a change to the code of Public Sub ProjectStartupActions()
. I added MsgBox("Hello")
to the first line in the sub, but it never pops up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这成功了!谢谢!!我使用配置管理器将整个解决方案的目标更改为 x86。
但为什么它有效呢?为什么“任何 CPU”选项在主项目上中断,但在库上却没有中断?
This worked! Thanks!! I used the Configuration Manager to change the target for the entire solution to x86.
But why did it work? Why did the "Any CPU" option break on the main project but not the library?
听起来您的项目依赖项不正确。确保主窗体项目依赖于具有
ProjectStartupActions()
函数的库 project(而不依赖于某些已构建的库程序集)。这应该使得 VS 在必要时重建库程序集并引用新构建的程序集。
您可能需要进行完全清理/重建才能再次同步。您可能还需要检查和更新您可能拥有的任何部署项目/脚本。
Sounds like your project dependencies aren't correct. Make sure that the main form project is dependent on the library project that has the
ProjectStartupActions()
function (and not dependent on some already built library assembly).This should make it so VS will rebuild the library assembly when necessary and refer to the newly built assembly.
You might need to do a full clean/rebuild to get things sync'ed up again as well. You might also need to check and update any deployment projects/scripts that you might have.