Partilhar via


C# Edit and Continue: error 4004 

Error Message

Editing or deleting an active statement on a constructor declaration will prevent the debug session from continuing while Edit and Continue is enabled.

This error indicates that you tried to edit an active constructor declaration. Edit and Continue does not support changes to active constructor declarations while debugging. For more information, see Active Statements.

Consider, for example, the following code:

class Program

{

   string arg;

   Program(): this(null)

   {

   }

   Program(string arg)

   {

      this.arg = arg;

   }

   static void Main()

   {

      Program p = new Program();

   }

}

If you set a breakpoint on this(null), debug the application and try to edit this(null) to be this("Hello"), the error occurs.

To fix this problem

  • Step through the code until you pass the constructor declaration. At that point, the changes will be automatically applied.

    —or—

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

    —or—

    End the debugging session, make your changes, and start a new debugging session.

See Also

Reference

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

Other Resources

Edit and Continue Errors and Warnings (C#)