Partager via


C# Edit and Continue: error 4008 

Error Message

Editing or commenting out an active statement inside a readonly section will prevent the debug session from continuing while Edit and Continue is enabled.

This error indicates that you tried to comment out an active statement inside a section that Edit and Continue has marked as read-only. Edit and Continue does not support changes to active statements while debugging.

For example, consider the following code:

class Program

   {

      static void Main()

      {

         Try

      {

   }

      Finally

      { System.Console.WriteLine("Example");

      }

   }

}

If you set a breakpoint on the Console.WriteLine, start to debug the application, and add /* before the try and */ after the closing brace of the finally, this error occurs.

To fix this problem

  • From the Debug menu, choose Undo to undo the changes

    -or-

    Click Stop Debugging, make the 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#)