VB.NET - Ctrl + Break 暂停“Partial Class frmMain”上的代码
这是 Visual Basic 2008 Express Edition 的 IDE 问题。这可能是 IDE 中的错误,或者可能是我的错?
我的主窗体名为 frmMain
,在应用程序的属性中,我已将 frmMain
设置为启动对象。所有这些似乎都是许多软件工程师所做的事情。
但是在调试时,我按了 Ctrl + Break,正如我多年来所做的那样,我在 IDE 中得到了我没有预料到的行为。这样做后,我得到绿色背景文本和工具提示中指示的绿色箭头:
这是该线程从当前函数返回时要执行的下一条语句。
即使我没有打开设计器文档,它也会自动在编辑器中打开 frmMain.Designer.vb
并以绿色显示 hihglights 行。该行当然是:Partial Class frmMain
,它是文件的第 2 行。 (是的,它突出显示了设计器生成的代码的第二行。)
frmMain
似乎已完全加载,它是我的启动对象。据我所知,根本不应该有“下一个要执行的语句”,因为代码应该是空闲的。我不想查看 Designer.vb
文档...我想编辑自己的代码。
这是什么原因造成的?即使我的表单表现得很好,加载表单时是否可能存在未完成的方面,导致它“不从函数返回”?
This is an IDE question for Visual Basic 2008 Express Edition. It might be a bug in the IDE, or maybe it's my fault somehow?
My main form is named frmMain
and in my application's properties I have set frmMain
as my startup object. All of that seems like what a lot of software engineers do.
But while debugging I hit Ctrl + Break, as I have done for years, and I get an behavior in the IDE that I wasn't expecting. Upon doing so, I get the green background text and the green arrow indicating in a tooltip:
This is the next statement to execute when this thread returns from the current function.
Even if I didn't have the designer document open, it automatically opens frmMain.Designer.vb
in the editor and hihglights line in green. The line is of course: Partial Class frmMain
which is line 2 of the file. (Yes, it's highlighting the second line of the designer-generated code.)
frmMain
seems to have fully loaded and it's my startup object. As far as I know, there shouldn't be a "next statement to execute" at all because code should be idle. I don't want to see the Designer.vb
document... I want to edit my own code.
What's causing this? Even though my form is behaving just fine, could there somehow be an unfinished aspect of loading the form such that it is "not returning" from a function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Visual Basic 编译器将在您的窗体中添加一个入口点。入口点是标准主函数或“共享子主函数”,其中又包含代码“application.run(new form)”。由于这是编译器生成的代码,没有源位置,因此 Visual Basic 编辑器会突出显示类定义。
线索就在调用堆栈中。注意
Main()
。The Visual Basic compiler will add an entry point in your form. The entry point is the standard main function or "shared sub main", which in turn contains the code "application.run(new form)". Since this is compiler generated code there is no source location, so the Visual Basic editor highlights the class definition.
The clue to this is in the call stack. Notice the
Main()
.我自己找到了答案:
我选中了解决方案属性中的“启用应用程序框架”复选框,一切都很好!
我相信这个问题是在我编写实验代码时出现的,我希望将 Sub Main 作为我的启动对象。我已清除该复选框,因为这样做是使用 Sub Main 所必需的。
当实验没有成功时,我将启动对象重置回 frmMain,并且我的应用程序运行良好。但是我没有重新检查该框。我已经好几天没有注意到 IDE 行为的变化(当我需要更标准的行为时),所以我没有观察到任何相关性。
虽然选中该框绝对是解决方案,但我仍然不太清楚这个框到底做了什么,除了让我在 StackOverflow.com 上花费大量时间! ;-)
对于遇到类似情况的其他人,我现在非常有信心我的设置没有损坏,如果您使用的是 Express 版本,请不要被 MS 文档误导,这可能会让您相信它是“只是我的代码”选项。此选项在 Express 版本中无法更改。 (但这并不是因为您无法打开它,而是因为您无法在 Express 中将其关闭!)
感谢大家的努力。
I found the answer on my own:
I checked the "Enable application framework" checkbox in the solution's properties, and all is well!
I believe this issue arose when I was working on experimental code in which I had desired to make Sub Main my startup object. I had cleared the checkbox because doing so is necessary to use Sub Main.
When the experiment didn't pan out I reset the startup object back to frmMain, and my app worked fine. However I had not re-checked the box. I hadn't noticed the change in the IDE behavior for several days (when I needed the more standard behavior) so I had not observed any correlation.
Although checking that box is definitely the solution, it's still not exactly clear to me is what the heck this box actually does, other than cause me to spend a lot of time on StackOverflow.com! ;-)
To others who encounter a similar situation, I'm now quite confident that my settings were not corrupt, and if you're using the Express edition, please don't be mislead by MS documentation which may lead you to believe it's the "Just My Code" option. This option cannot be changed in the Express versions. (But it's not because you can't turn it on -- It's because you can't turn it OFF in Express!)
Thanks to everyone for your efforts.
我猜测它试图向您展示相当于:
这是为启动表单而生成的代码。但在 VB.NET 中,这段代码被隐藏了。创建一个
Main()
函数并将启动类型更改为包含此行的启动类型,然后重复该过程。您会看到它突出显示Application.Run
。这是包含 Windows 消息泵循环的方法。I'm going to guess that it is trying to show you the equivalent of:
This is the code that gets generated to startup your form. But in VB.NET this code gets burried. Create a
Main()
function and change your startup type to that with this line in it and repeat the process. You'll see it highlightApplication.Run
. That is the method that contains your Windows message pump loop.