Partilhar via


C# Edit and Continue: error 4022 

Error Message

Deleting a block around an active statement will prevent the debug session from continuing while Edit and Continue is enabled

This error indicates that you tried to delete an exception-handling block around an active statement, which Edit and Continue does not support while debugging.

Consider the following code:

class Program

{

   static void Example() { }

   static void Main()

   {

      foreach (char c in "Example")

      {

         Example();

      }

   }

}

If you set a breakpoint on the opening brace of the Example method, then start debugging and delete the foreach statement, including the curly braces but not the call to Example, this error occurs.

To correct this error

  • Undo the changes, and then continue debugging without the changes.

    —or—

  • On the Debug menu, click Stop Debugging, then make the changes, and start a new debugging session.

See Also

Reference

try-catch-finally (C# Reference)
Supported Code Changes (C#)
Edit and Continue (Visual C#)

Other Resources

Edit and Continue Errors and Warnings (C#)