Share via


C# Edit and Continue: error 4003 

Error Message

Editing or deleting an active statement inside of an anonymous method will prevent the debug session from continuing while Edit and Continue is enabled.

This error indicates that you tried to edit an active statement within an anonymous method.

For example, consider the following code:

class Program

   {

      delegate void D();

      static void Main()

      {

         D d = delegate

         { System.Console.WriteLine("Inside anonymous method");

      };

      d();

   }

}

If you set a breakpoint on the line with the System.Console.WriteLine call, then debug the application and try to edit the WriteLine call, this error occurs.

For more information, see Active Statements.

To correct this error

  • Undo the changes, and then continue debugging without the changes. You can make the edits later when the statement is no longer active.

    —or—

    On the Debug menu, click Restart.

    This will end the debug session and start a new session.

See Also

Reference

Supported Code Changes (C#)
Edit and Continue (Visual C#)
Anonymous Methods (C# Programming Guide)

Other Resources

Edit and Continue Errors and Warnings (C#)