Jump to content

[Resolvido] System.Data.Linq.DataContext is defined in an assembly that is not referenced


nunolevezinho

Recommended Posts

Boas, estou com um erro um pouco chato ja ha algum tempo e nao consigo resolver nem por nada :\

O erro está numa class chamada Geral que usa Linq2SQL. Supostamente o erro que me dá é que não adicionei a reference ao projecto mas ja verifiquei umas 10 vezes e está la adicionado.

public bool IsvalidUser(string Username, string Password)
    {
	    Password = getMD5Hash(Password);

	    BaseDadosInforDataContext db = new BaseDadosInforDataContext(); //The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

	    var query = from p in db.Funcionarios
				    where p.Utilizador == Username
				    && p.Password == Password
				    select p;
	    if (query.Any())
	    {
		    return true;
	    }
	    else
	    {
		    return false;
	    }
    }
Estive ja a pesquisar na net sobre este erro e dizem mesmo para tentar adicionar manualmente a assembly no web.config. Já o fiz e continua sem dar :\

Alguma sugestão?

Link to comment
Share on other sites

qual e' a versao da .Net framework que estas a utilizar?

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

muda o projecto para a 4.0, e volta a fazer referencia.

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

Estive a testar aqui no meu VS12 e funciona perfeitamente, ate' removi a referencia do linq e mesmo assim funciona.

Esta' aqui o teste que estou a fazer, so' bastou meter o using do linq

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;


namespace DragDropOutlook
{
   public partial class Form1 : Form
   {

    public Form1()
    {
	    InitializeComponent();
           List<int> list = new List<int>();
           for (int i = 0; i < 25; i++)
               list.Add(i);
           var query =  from e in list
                        orderby e descending
                        select e;
           foreach (var item in query)
               MessageBox.Show(item.ToString());
   }
  }
}

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

Será por estar a fazer em website asp.net ? tem alguma diferença para a consola C# ? é porque eu faço tal e qual como tu e quando compilo o website ele dá erro ao abrir a página 😕

Ou seja no IDE está tudo muito bem nem da warnings, quando compilo a abro a página no browser ele dispara logo o erro 😕

http://img267.imageshack.us/img267/5259/84713955.png

Link to comment
Share on other sites

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.