Partilhar via


C# Edit and Continue: Erro 4054

Modifying a 'method | property | indexer | operator' which contains the 'yield return' or 'yield break' statement will prevent the debug session from continuing while Edit and Continue is enabled

Este erro ocorre se você tentar modificar um método, propriedade, indexador ou operador contendo uma yield return ou yield break instrução. For more information, see rendimento (referência de C#). Edit and Continue does not support this change during debugging.

Consider the following code:

class Program

{

   private int[] items = { 1, 2, 3 };

   System.Collections.Generic.IEnumerable<int> Range(int start, int end)

   {

      for (int index = start; index < end; index++)

      {

      yield return items[index];

      }

   }

   static void Main()

   {

      Program p = new Program();

      foreach (int item in p.Range(0, 2))

      {

         

      }

   }

}

Se você definir um ponto de interrupção em yield return items[index], em seguida, iniciar a depuração e tente adicionar uma declaração de variável local int a = 10 na Range método, este erro ocorre.

To correct this error

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

    —or—

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

Consulte também

Referência

rendimento (referência de C#)

Alterações de código suportadas (C#)

Edição e continuação (Visual C#)

Outros recursos

Editar e continuar a erros e avisos (C#)