共用方式為


Did you know… You can debug an executable that isn’t a part of a Visual Studio project without using Tools – Attach to Process? - #296

And yet another, “I would have never thought to do that” feature in Visual Studio.

There’s the standard Tools – Attach to Process dialog that allows you to attach and debug any process currently running on your machine. But if you’re trying to debug an issue that occurs at startup (meaning the application fails or crashes before you can attach to it) or if the application finishes too quickly before you can attach, there’s still a way to debug it.

Go to File – Open Project and give it the name of the executable. Yes, even thought it isn’t a “project” per se, like a .proj or .sln, the dialog will accept an executable.

Opening notepad.exe as a VS project

Now you’ll see the executable opened in Solution Explorer as a project.

notepad in solution explorer as a project

Just hit F5 as usual to start the executable.

Technorati Tags: VS2005Tip,VS2008Tip

Comments

  • Anonymous
    August 20, 2008
    PingBack from http://hoursfunnywallpaper.cn/?p=2440

  • Anonymous
    August 21, 2008
    I'm not an expert in debugging, but don't you need symbols or .pdb files in order to debug a process?

  • Anonymous
    August 21, 2008
    My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. The Web Developer Tools Team announced the release of the Dynamic Data Wizard Preview 0806 for VS 2008 SP1 . US ISV Developer Evangelism

  • Anonymous
    August 21, 2008
    I had not a clue you could do this!  I've claimed in the past this wasn't possible, no I'm changing my tune!  Thanks for the tip!

  • Anonymous
    August 21, 2008
    While I can usually figure out the menu items and options checkboxes myself, this is exactly the kind of non-intuitive but awesome tip that keeps me coming back for more! Go Sara Go!

  • Anonymous
    August 21, 2008
    Why can't I tag this great info?

  • Anonymous
    August 21, 2008
    You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • Anonymous
    August 21, 2008
    That's great!  How do you do it with a Windows Service?

  • Anonymous
    August 21, 2008
    The same goes for dump and minidump files. --larsw

  • Anonymous
    August 27, 2008
    In Visual Studio 2008 Professional SP1, I'm not able to open an Executable with "Open Project...", only with "Open File...". I get the error "The selected file cannot be opened as a solution or project.  Please select a solution file or project file."

  • Anonymous
    September 12, 2008
    If I m not mistaken, shouldn't the last step be to press F10???

  • Anonymous
    September 12, 2008
    The comment has been removed

  • Anonymous
    January 15, 2009
    本篇包括tip291-tip300http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-29.html#291、启动时...