Partager via


C# Edit and Continue: error 4005 

Error Message

Editing or deleting an active statement in a field initializer will prevent the debug session from continuing while Edit and Continue is enabled

This error indicates that you tried to edit an active statement in a field initializer. Edit and Continue does not support changes to active statements while debugging. For more information, see Active Statements and Fields (C# Programming Guide).

Consider the following code:

class Program

{

int a = 100;

static void Main()

{

Program p = new Program();

}

}

If you set a breakpoint on int a = 100, debug the code, and try to change 100 to 50, the error occurs.

To fix this problem

  • Step through the code until the current statement is no longer in the field initializer.

    —or—

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

    —or—

    End the debugging session, make your changes, then 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#)