Share via


C# Edit and Continue: error 4032 

Error Message

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

This error occurs when you try to edit a catch or finally handler whose try block contains an active statement. It occurs only if the active frame is not on the top of the callstack. Edit and Continue marks catch and finally handlers as read-only, so this error occurs only in unusual cases.

Consider the following example code:

#define EXAMPLE

class Program

{

   static void Example()

   {

      ...

   }

   static void Main(string[] args)

   {

      try

      {

         Example();

      }

#if EXAMPLE

      catch

      {

       ...

      }

#else

      catch(exception e)

      {

         ...

      }

#endif

   }

}

If you set a breakpoint on the call to Example, then change #define EXAMPLE to #define EXAMPLE2, 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#)