C# Edit and Continue: error 4028

Modifying a generic method will prevent the debug session from continuing while Edit and Continue is enabled

This error indicates that you tried to modify a generic method. Edit and Continue does not support any modifications to the body of a generic method. It does support adding a call to a generic method however.

Consider the following code:

static class Utils

{

   public static T[] CreateArray<T>(int size)

   {

      return new T[size];

   }

}

class Program

{

   static void Main(string[] args)

   {

      int[] array = Utils.CreateArray<int>(10);

   }

}

If you add a breakpoint on return new T[size] in CreateArray, then start to debug the application and try to change size to size + 1, this error occurs.

To correct this error

  • Undo the changes, and then continue debugging without the changes.

    —or—

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

See Also

Reference

Generic Methods (C# Programming Guide)

Supported Code Changes (C#)

Edit and Continue (Visual C#)

Other Resources

Edit and Continue Errors and Warnings (C#)