Partilhar via


C# Edit and Continue: error 4034 

Error Message

Modifying a catch handler around an active statement will prevent the debug session from continuing while Edit and Continue is enabled

You tried to edit a catch handler that contains a currently active statement but is not on the top of the call stack. Edit and Continue does not support this type of change while debugging.

Consider the following example code:

class Program

{

   static void Example() { }

   static void Main(string[] args)

   {

      try

      {

         throw new System.Exception();

      }

      catch

      {

         Example();

      }

   }

}

If you set a breakpoint on the call to Example, then start to debug the application and try to remove the call to Example in the catch handler, this error occurs.

To correct this error

  • Undo the changes, then continue debugging without the changes. You can make the changes later when the catch handler no longer contains an active statement.

    —or—

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

See Also

Reference

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

Other Resources

Edit and Continue Errors and Warnings (C#)