The method or Operation is not implemented error

Asked

Viewed 1,291 times

3

When I will add a record on my Include screen, I get this error.

What can it be?

Service

public void AddItem(Test item)
        {

            var codigos = this.context.Tests.SingleOrDefault(x => x.Codigo == item.Codigo);
            if (codigos != null)
            {
                this.context.Testes.Any(x =>
                x.Id == codigos.Id
                && x.Codigo != item.Codigo);
                throw new ValidationException("Codigo", Resources.TestesResources.ErroUniqueKeyCodigo);
            }
            else
            {
                base.context.Tests.Add(item);
                base.Save();

            }

        }

Controller

[HttpPost]
 public ActionResult Incluir([ModelBinder(typeof(CollectionModelBinder))]Testitem)
        {
            if (this.ModelState.IsValid)
            {
                item.Id = this.Id;
                item.Value = DateTime.Now;
                item.Use = User;
                try
                {                    
                    this.Service.AddItem(item);
                    return this.SuccessView(true);
                }
                catch (ValidationException exception)
                {
                    base.AddValidationErrors(exception);
                    return base.PartialView(item);
                }
            }
            else
                return base.PartialView(item);
        }

Error

Foto do Erro

  • Can you debug and tell exactly which line gives the error ?

  • I put some breakpoints in the code it doesn’t even fall into the methods when debug.

  • 3

    In that screenshot, you left out the most important part: the stack trace. Put the stack trace here, and put the relevant code where the exception was launched.

  • Put the Validationexception code, please

1 answer

2

Most likely you used code generators where you generate methods in the following format:

void MeuNovoMetodo () {
    throw new NotImplementedException ();
}

They do this so that your code can compile but you don’t forget to implement it later. You will only find out which method you forgot to implement by looking at the stack trace, or by searching the files through Notimplementedexception Exception.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.