Error CS0012 The type 'Client' is defined in an Assembly that is not referenced

Asked

Viewed 1,271 times

0

Handling class with RU:

ContextEF Contexto = new ContextEF();

public List<Cliente> Listar()
    {
        //var query = from c in Contexto.Cliente
            //          select c;
        return Contexto.Cliente.ToList() ;
    }

Onclick of the consultation page

protected void btnPesquisar_Click(object sender, EventArgs e)
    {
        ClientService service = new ClientService();
        var lista = service.Listar();

        gvListacEF.DataSource = lista;
        gvListacEF.DataBind();
    }

Error presented:

Error CS0012 The type 'Client' is defined in an Assembly that is not referenced. You must add a Reference to Assembly 'DAO, Version=1.0.0.0, Culture=neutral, Publickeytoken=null'

  • Have you renamed this class recently? This dll? Did you merge some where there was conflict of reference?

  • I have not renamed either the class or the dll. .

  • 1

    You referenced this Assembly (DAO) in the current Assembly?

  • No. I’m trying to recreate the project to see what I might have done wrong.

  • 1

    That’s the problem, you’re using that Assembly DAO but you haven’t added the reference in your current Assembly. Tell me if doing this works.

  • Boy, it worked. Thank you very much. I didn’t know that detail, I’m learning Asp.net.

Show 2 more comments

1 answer

1


I’m commenting on the response that was made in the comment to remove her from the "No Response"

The problem is that you are trying to use a namespace (using DAO) of an Assembly not yet referenced in its current application:

To do this, go on Reference > Add Reference... > Projects > Solution and select the desired Assembly (in your case the DAO).

Next time you build a build the error will disappear.

For more details, I recommend the MSDN: https://msdn.microsoft.com/en-us/library/wkze6zky.aspx

Browser other questions tagged

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