Debugging without executing your application

Sign in to queue


I came across Habib Heydarian's blog and he has one of the coolest tips I've seen in a while with debugging.  Habib shows how to debug an application without actually running it.

He uses the Immediate Window (Debug –> Windows –> Immediate Window) to actually create an instance of the Window then uses the Show Dialog method to display it.  Since this code is executing, it will trigger break points in your code! 

Via [10-4 episode on the Historical Debugger in Visual Studio 2010]

The Discussion

  • User profile image

    Great...!!! I'll try it right now.

  • User profile image
    Steve Bargelt

    Really? 1) it takes longer to type the friggin' commands out then to hit F5 and click a button. 2) How many sub form don't depend on some data being passed from a parent form. 3)He states there is NO WAY to set your startup form? Huh? The app just picks one at random? I think NOT!

  • User profile image

    @Steve Bargelt, if you have an application that has tons of forms, it can become very time consuming to click through everything to get to the item you want.  And then you can test, close, tweak, hit up in the intermediate window which will repeat the last command, hit enter and bam, it repeats.  If a form needs data sent, you may be able to mock it out.  This may not work in every scenario but it is one tool to help out.

    He is wrong regarding no way to declare what form is the start up form.  That can be configured in App.Xaml by changing the StartupUri attribute in the root.

    Good catch.

  • User profile image

    One thing to know is that for C# projects Visual Studio actually starts a debugging session for you behind the scene.

Add Your 2 Cents