jeudi 3 avril 2008 17:46Ok first of thank you in advance for any advice or suggestions...
I am currently working on a small web application and decided to use LINQ to serve as as the means from which i will access my SQL Server DB. I created the db tables and structure from within VS and then added a new 'linq to SQL class' in my wem application project. I imported all tables in the designer view of my LINQ to SQL class and saved to generate the underlying DataContext code. I then moved on to create a data access layer class (DALProfile) to manage any requests to the db through LINQ. the class imports the following namespaces:
Code Snippetusing System.Data.Linq;
and i access the LINQtoSQL class through an instance of the dataContext like this:
public static class ProfileDAL
private static DBLinqDataContext objDataContext = new DBLinqDataContext();
now when i build the application from within VS 2008 everything compiles without an error... but when i run it i get the following error:
Compiler Error Message: CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
Line 1: using System.Data.Linq;
and i triple checked my project references... both System.Core and System.Data.Linq appear....
funny thing is i get a compile error for the DAL class but not the generated LINQtoSQL class code.... and ia lso ensured my project was set to use the 3.5 framework.
and as an FYI my DAL classes are in a subfolder called "DataAccess"
any help is greatly appreciated
Toutes les réponses
mercredi 16 avril 2008 16:14
Not sure if this applies to your case by I ran into this problem.
Check your web.config file - do you see a reference to System.Data.Linq within the compilation/assemblies section?
Depending on how you originally created your project the web.config file may not get updated when adding references to your project. It would appear that "File/New/Project/asp.net web application" behaves differently to "File/New/Website" as under the latter when adding a reference to System.Data.Linq.dll this also automatically updates the web.config file whereas under the former it doesn't!
To fix this add to the web.config under the section mentioned above the following:
where the public key token is the same as that used to sign System.Data.DataSetExtensions
Hope this helps.
mercredi 16 avril 2008 16:23
Thanks for the suggestion... I actually found this after digging a little deeper. My web.config did not have the assembly line for the Data.Linq assembly.... very frustrating that visual studio didn't do this on.
Either way that was the problem Thanks.
mardi 7 octobre 2008 14:37I was having this problem as well and adding the assembly declaration to the web.config worked for me too. I was just wondering if there's a any way this assembly can be added automatically when you create a new web application project, or are we stuck with having to type it manually each and every time?
mardi 7 octobre 2008 14:45
vendredi 17 octobre 2008 15:50THANK YOU! Your suggestion worked for me also.
jeudi 5 août 2010 13:33
Also experienced this problem. I removed everything from "references" and compiled and then slowly added the references it required from scratch.
After that it worked. Some somehow, the references in my project got messed up.
mercredi 7 mars 2012 06:57
This has worked for me
Right-click on the project's name in solution explorer => Add reference =>.NET Tab=> select System.Data.Linq => Press OK