Share via


C# Edit and Continue: error 4002 

Error Message

Editing or deleting an active statement which is not at the top of the callstack will prevent the debug session from continuing while Edit and Continue is enabled

This error indicates that you tried to edit a statement that called a function currently on the call stack. Edit and Continue does not support applying this type of change. For more information, see Active Statements.

The following example code shows how this error occurs:

class Program

   {

      static void Example()

   {

   System.Console.WriteLine("Example");

   }

   static void Main()

   {

   Example();

   }

}

If you set a breakpoint on Console.WriteLine and start to debug the application, trying to edit the line in main that calls Example will cause this error.

To correct this error

  • Step through the code until the statements are no longer active, then make the desired edits.

    —or—

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

    —or—

    Stop debugging, make the edits, then restart the debugging session.

See Also

Reference

Supported Code Changes (C#)
Edit and Continue (Visual C#)

Other Resources

Edit and Continue Errors and Warnings (C#)