3

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anonymous Penguin
  • 2,027
  • 4
  • 34
  • 49
  • Years later I ran into this same problem and I went into Debug settings and turned off "Enable Just My Code" - thought this might help someone – Jamie Jun 11 '21 at 15:46

5 Answers5

2

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.

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.

xpda
  • 15,585
  • 8
  • 51
  • 82
  • I've set a breakpoint in the "Form_load" method, however, it never reaches the first statement. I'm assuming that it's #2; I've tried changing which form loads first and it doesn't work. This is a sudden change. I used to be able to run it, but it doesn't run now, and I didn't change any code to my knowledge. What do I do next? How can I diagnose this problem? – Anonymous Penguin Oct 08 '13 at 00:05
  • Check your dim statements. If any have an initialization ( = ) or instance definition ( as new ), then move that part out below the dims. If there is a problem before the form initializes, it may not give an error (even though it should). – xpda Oct 08 '13 at 01:54
  • Also, check under project properties, Application, Startup Object and make sure it is the form you're expecting it to be. You can set a project to start on any form or sub. – xpda Oct 08 '13 at 01:56
  • 1
    Also look at the output window in VS and see if there is anything displayed there. Check the Windows Event Log as well. Another thing to try is to navigate to the .exe and run it directly from the command line or Windows Explorer and see if anything happens. – Chris Dunaway Oct 08 '13 at 14:24
  • @ChrisDunaway Tried launching the exe, didn't work. How can I find the Event Log on XP? Looking at the output window | xpda: look at my last comment in Derek's answer; I single stepped it. It seems like an error before it initializes. Also, what do you mean by the Startup Object? I said I tried changing the startup form, or is that something different? Thanks. – Anonymous Penguin Oct 08 '13 at 21:56
  • @AnnonomusPerson - For XP, right click My Computer and select Manage from the menu. On the Computer management screen, you should see the Event Viewer. You can then look at the application logs and see if anything is showing for your app. – Chris Dunaway Oct 09 '13 at 14:29
1

A few ideas:

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

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

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

Derek
  • 7,615
  • 5
  • 33
  • 58
  • But there's no notification of a exception; I think that one would be labeled. – Anonymous Penguin Oct 08 '13 at 00:01
  • You are probably right, but you could try it. And you should really try "Debug-->StepInto" and start stepping into the code :) – Derek Oct 08 '13 at 11:31
  • Tried that, it loaded a new page saying, "No symbols loaded for any call stack frame. Source Code Cannot be Displayed." It also says the location of the call stack, do you want that? – Anonymous Penguin Oct 08 '13 at 21:47
  • I would say try to keep stepping until you hit some of your code. Learn the keyboard shortcuts for step in/ step out/ step over. Did you do the exception idea? – Derek Oct 08 '13 at 22:17
  • Haven' tried the exception yet. Also, the second step is my first line of code, which is to select the first item in a combobox, which is already populated. Also, I've tried commenting it out. – Anonymous Penguin Oct 09 '13 at 01:55
  • Try the exception idea. Especially now that we know you are getting into your code. If you do that, try to debug and you don't hit one, you should keep stepping through your code until you see where it fails. The other thing you can do is search your whole project for the word "Close". Maybe you are closing the form somewhere. – Derek Oct 09 '13 at 11:14
  • There is no exceptions option in the debug menu. Also, for close, wouldn't stepping find that? – Anonymous Penguin Oct 09 '13 at 20:25
  • Are you using Visual studio Express? Searching all of the code for the word close shouldn't be too difficult. How far have you got into your stepping? Have you found a place where you step and then the program closes? – Derek Oct 10 '13 at 11:12
  • Yes VS E 2010. I can get through two steps, and it closes on the first, showing me that one page with the "No symbols loaded for any call stack frame. Source Code Cannot be Displayed." **Edit:** Fixed it and posted an answer. – Anonymous Penguin Oct 10 '13 at 21:41
0

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.

Community
  • 1
  • 1
Anonymous Penguin
  • 2,027
  • 4
  • 34
  • 49
0

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)

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.

Russia Must Remove Putin
  • 374,368
  • 89
  • 403
  • 331
craisin
  • 61
  • 1
  • 1
0

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.

JWC May
  • 605
  • 8
  • 14