rf_wilson
rf_wilson

Reputation: 1582

LinqDataSource throws System.Data.Linq.Mapping.DataAttribute is not defined error

I am using an ASP.net Website project in VB.net and have added a LINQ to SQL data class to it in order to use a number of LinqDataSource controls. Yesterday my project worked fine but after shutting down last night and starting up this morning I now get this error:

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'System.Data.Linq.Mapping.DatabaseAttribute' is not defined.

Source Error:

<Global.System.Data.Linq.Mapping.DatabaseAttribute(Name:="xxxx_pcf")>  _
Partial Public Class PCFDataContext
    Inherits System.Data.Linq.DataContext

This file is auto-generated by Visual Studio 2010 but it throws no errors. I only get the error at runtime.

Elsewhere on the internet people have recommended removing the Namespace declaration, only I don't have one.

I also found here somebody saying that the reference to System.Data.Linq might be missing from the web.config file. Not for me though, my web.config is ok.

Also here a warning about VS renaming your classes for pluralization reasons - again not valid for me.

So I am stuck.

Upvotes: 3

Views: 2658

Answers (2)

Sriniwekh Ravindran
Sriniwekh Ravindran

Reputation: 123

I had the similar issue when I used LINQtoSQL(vb.net) in my website(.net 4.0 framework) for the first and rolled it out to the live server. It was working fine in my local server.

All I did is adding the below lines in my web.config

<page>
 <namespaces>
    <add namespace="System.Data.Linq" />
    <add namespace="System.Linq" />
 </namespaces>
</Page>
<system.web>
  <assemblies>
    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
     <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  </assemblies>
</system.web>

It worked for me,worth a try my friend...

Upvotes: 6

Divi
Divi

Reputation: 7701

It looks like its a problem with VB only and C# does not face the same issue. Have a look here. Hope it helps

Upvotes: 0

Related Questions