Partilhar via


C# Edit and Continue: error 4059 

Error Message

Modifying a '[method | property | indexer | operator | event | accessor | constructor | destructor]' containing an active statement in compiler generated code will prevent the debug session from continuing while Edit and Continue is enabled

You tried to modify a method, property, indexer, operator, event, accessor, constructor, or destructor containing an active statement in compiler-generated code. Edit and Continue does not support this change during debugging.

Consider the following code:

class Disposable: System.IDisposable

{

   public void Dispose()

   {

   }

}

class Program

{

   static void Main(string[] args)

   {

      int a = 10;

      using (Disposable dipose = new Disposable())

      {

      }

   }

}

If you set a breakpoint in the dispose method, then start to debug the application and try to change int a = 10 to int a = 20, this error occurs.

To correct this error

  • On the Edit menu, click Undo to undo the changes

    -or-

    On the Debug menu, click Stop Debugging, then make the 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#)