Nick Devereaux
Nick Devereaux

Reputation: 833

Application rarely completes loading in debug mode, but "run without debug" loads fine

This gets annoying if I want to change code and have it reflected straight away.

Would this have something to do with loading source for symbols? I've tried pausing the application when run under normal debug mode but it'll be paused in a different place each time.

Edit: By stalling I mean the application is frozen (splash form with progress bar becomes unresponsive after loading fine for a few seconds). If I hit pause, the main thread's location is never consistent. It will eventually complete loading, after some point, indicating that it's waiting for something, although this waiting period seems to change as well.

Symbol server for Microsoft pdbs is unchecked. Enabled .NET Framework source stepping is unchecked. Enabled Just My Code is checked. Enabled source server support is unchecked.

Upvotes: 3

Views: 563

Answers (1)

ogggre
ogggre

Reputation: 2264

A known but sporadic problem, has a long history since Visual Studio 2005. The problem affects multithreaded applications which do some I/O operations with completion callbacks. My personal receipt to workaround this issue:

  • Developer machine should have at least 2 CPU cores
  • Delete all breakpoints from Breakpoins window. Sometimes outdated ones lead to infinite cycling of debugger
  • Set a breakpoint at the very beginning of the program, preferably at the main function. If you have a main form, then you can try to set a breakpoint on a first line of its constructor. Do not remove that breakpoint - otherwise debugger will start to hang again and you would need to set it again. Yes, the breakpoint seems to be useless but it helps the debugger to stay in a good condition
  • If the suggestions above do not help then try to invoke System.Window.Forms.MessageBox.Show("123") at the very beginning of the program if the application is windowless. You may also try to set a breakpoint on or after Show method

Upvotes: 1

Related Questions