Partilhar via


C# Edit and Continue: error 4033 

Error Message

Modifying a try/catch/finally statement when the finally block is active will prevent the debug session from continuing while Edit and Continue is enabled

This error occurs when you try to edit a try, catch or finally statement when the corresponding finally block contains an active statement. This error occurs only if the frame containing that active statement is not on the top of the call stack. For more information, see Active Statements.

Consider the following example code:

class Program

{

   static void Example() { }

   static void Main(string[] args)

   {

      try

      {

         int a = 100;

      }

      finally

      {

         Example();

      }

   }

}

If you set a breakpoint on the call to Example, then debug the application and try to change a = 100 to a = 10, this error occurs.

To correct this error

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

    —or—

    On the Debug menu, click Stop Debugging, then make the changes and start a new debugging session.

See Also

Reference

try-catch-finally (C# Reference)
Supported Code Changes (C#)
Edit and Continue (Visual C#)

Other Resources

Edit and Continue Errors and Warnings (C#)