为什么 Visual Studio 不调试我的 VB.NET 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19235917/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 15:23:29  来源:igfitidea点击:

Why doesn't Visual Studio debug my VB.NET application?

vb.netvisual-studio-2010vb.net-2010visual-studio-express

提问by Anonymous Penguin

I recently have encountered a weird issue with my project: as soon as I click debug and it builds the project, it stops debugging. There isn't any error message, or anything else that comes up, including the form itself.

我最近在我的项目中遇到了一个奇怪的问题:只要我单击调试并构建项目,它就会停止调试。没有任何错误消息,或出现任何其他内容,包括表单本身。

I've tried messing with the settings: no splash screen and I've even changed the startup form to a blank Windows form. What could be causing this problem? Is it Visual Studio or my code?

我试过搞乱设置:没有启动画面,我什至将启动表单更改为空白的 Windows 表单。什么可能导致这个问题?是 Visual Studio 还是我的代码?

采纳答案by Anonymous Penguin

I found a solution, but not the problem.

我找到了解决方案,但不是问题。

How I fixed it:

我是如何修复它的:

I just created a template for each form, created a new project, and imported everything into the new project. One thing that I found useful is in the new project is to add an existing item (CTRL + D), and group select (maybe, don't know if you can) and select all the non-code/form/designer/etc. files (like text files or images) and then import them.

我只是为每个表单创建了一个模板,创建了一个新项目,并将所有内容导入到新项目中。我发现在新项目中有用的一件事是添加一个现有项目 ( CTRL + D),然后分组选择(也许,不知道是否可以)并选择所有非代码/表单/设计师/等。文件(如文本文件或图像),然后导入它们。

回答by xpda

Probably your program is exiting normally. Set a breakpoint at the first statement to be executed, press F5, then single-step through the program until you get to the last statement executed.

可能您的程序正在正常退出。在要执行的第一条语句处设置断点,按 F5,然后单步执行程序,直到执行到最后一条语句。

If the first statement is never reached, then one of two things probably happened:

如果第一条语句从未达到,那么可能发生了两件事之一:

  1. You're mistaken about which statement is executed first, or

  2. The program is terminating during initialization, probably because a class constructor is exiting the program either normally or abnormally.

  1. 你对先执行哪个语句有误,或者

  2. 程序在初始化期间终止,可能是因为类构造函数正常或异常退出程序。

回答by Derek

A few ideas:

一些想法:

Use Debug->Exceptions, and check all the checkboxes so you break when an exception is thrown.

使用 Debug->Exceptions,并选中所有复选框,以便在抛出异常时中断。

Use Debug->Step into to step into your code.

使用 Debug->Step into 进入你的代码。

Then you can use Step Over and Step Into (look at the menu for the keyboard shortcuts)

然后你可以使用 Step Over 和 Step Into(查看键盘快捷键的菜单)

回答by craisin

I have found a possible solution after I had the same problem.

遇到同样的问题后,我找到了可能的解决方案。

You probably have more than one project in your solution (The main project, plus an "InstallShield" project",perhaps)

您的解决方案中可能有多个项目(可能是主项目,加上“InstallShield”项目)

Make sure you have the main project set up as "Startup Project".

确保将主项目设置为“启动项目”。

In the Solution Explorer, right click on the Main Project and select "Set as Startup Project". Everything will then run OK.

在解决方案资源管理器中,右键单击主项目并选择“设置为启动项目”。然后一切都会正常运行。

回答by JWC May

If you get the error like: "The debug mode is program but there is no program specified....." Go to Solution Explorer then Right Click on main project's name and Click on Set as StartUp project. You can debug your program.

如果您收到类似这样的错误:“调试模式是程序,但没有指定程序.....”转到解决方案资源管理器,然后右键单击主项目的名称,然后单击设置为启动项目。你可以调试你的程序。