System.Diagnostics.Debugger.Break()
As suggested by Muhimbi, in some cases it is very useful. Suppose you want to debug your own code (for example, the feature_deactivating event) when it can be called using stsadm, and not with a browser. (for example, you have to use stsadm to deactivate a function when the function is hidden in the user interface). When using stsadm you cannot attach to cmd.exe because it is a separate process. If you type the command and press "Enter" and then find your stsadm.exe process id to join it, it's too late. In such situations, the team above is the simplest and best solution.
source share