December 15th, 2021
like1 reaction

What does “Do not launch, but debug my code when it launches” mean?

Visual Studio has an option called Do not launch, but debug my code when it launches.

For a long time, I was confused by this setting. It’s like telling someone, “Don’t drive my car, but wear a seat belt when you drive my car.”

I also tried to parse this as

(Do not launch, but debug my code) when it launches.

In other words, “When my code launches, don’t launch it; just debug it.”

Which makes no sense. “When my code launches, don’t launch it.”

I eventually got clued in that both of those attempts at parsing the statement were incorrect. The intended parse is

Do not launch, but (debug my code when it launches).

In other words, “Don’t launch it right now. Wait for somebody else to launch it, and then debug it when that launch happens.”

Topics

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

16 comments

Discussion is closed. Login to edit/delete existing comments.

Sort by :
  • Gustavo Lopes

    The two uses of launch are different predicates, one with two places (transitive) and one with only one place (anticausative). It’s analogous to the storm sank the ship, so the ship sank. This is called causative alternation.

  • Mike Morrison

    Perhaps a single additional word would have alleviated some of the confusion: “Do not launch now, but debug my code when it runs”.

  • Ivan K

    Very useful. I was wondering how this is implemented, but currently searching all the google for “Do not launch, but debug my code when it launches”, or just “debug my code when it launches” only finds this blog entry. A guess would be some user-mode windows api trace call (WMI apparently can do it), or even IFEO if it handles Visual Studio not already running when launch occurs. It could also add code or some dependency during app build so extra stuff happens at process launch.

    • David Trapp · Edited

      I would assume it temporarily sets AeDebugger for the filename to itself (and when it’s invoked first checks if it’s actually the right file and not just the right filename, and if it isn’t, runs the process normally and detaches).