Debug - "Unable to attach"

If this error message appears when starting the debugger in order to debug a TwinCAT C++ project, then a configuration step is missing:

Debug - "Unable to attach" 1:


In this case, navigate to System -> Real-Time, select the C++ Debugger tab and activate the option Enable C++ Debugger.

Debug - "Unable to attach" 2: