F5 vs. Ctrl-F5
In VS, F5 will launch your application under the debugger. Under the
debugger, you'll hit breakpoints, be able to edit-and-continue, and do all the
debugger things you know and love.
Ctrl+F5 will launch your application outside of the debugger. This is like
launching your app from the "start | run" menu, except VS becomes the parent
process instead of explorer. Ctrl+F5 is purely convenience functionality.
Ideally ,
running under a debugger shouldn't change the app's behavior. An app may do
something evil, like
detect if a debugger is attached to itself, and use that to do different
behavior.
Under the covers, they both translate to calls to CreateProcess. The
questions are:
1) what version of CreateProcess do you call?
kernel32!CreateProcess is the OS API to create a process. ICorDebug::CreateProcess
has the same signature as kernel32's, but the ICorDebug version will launch the
program as a managed debuggee.
2) what flags do you pass? CreateProcess takes a set of
flags. If you pass (DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS) to the flags,
then the child process will be a native.
If you enable both managed + native debugging, then you've enabled
interop-debugging.
Here's a matrix:
F5 (under debugger) | Ctrl+F5 (outside debugger) | |
Managed-only | ICorDebug::CreateProcess, 0 flags | kernel32!CreateProcess, 0 flags |
Native-only | kernel32!kernel32!CreateProcess, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS | kernel32!CreateProcess, 0 flags |
Interop (aka Mixed-mode) | ICorDebug::CreateProcess, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS | kernel32!CreateProcess, 0 flags |