gpt4 book ai didi

vb.net - LinqDataSource 抛出 System.Data.Linq.Mapping.DataAttribute is not defined 错误

转载 作者:行者123 更新时间:2023-12-01 05:43:28 24 4
gpt4 key购买 nike

我在 VB.net 中使用一个 ASP.net 网站项目,并向其中添加了一个 LINQ to SQL 数据类,以便使用多个 LinqDataSource 控件。昨天我的项目运行良好,但在昨晚关闭并在今天早上启动后,我现在收到此错误:

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.

来源错误:

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

此文件由 Visual Studio 2010 自动生成,但不会引发任何错误。我只在运行时收到错误。

在互联网的其他地方,人们建议删除命名空间声明,但我没有。

我还找到了here有人说 web.config 文件中可能缺少对 System.Data.Linq 的引用。虽然不适合我,但我的 web.config 没问题。

还有 here关于 VS 出于多元化原因重命名您的类的警告 - 对我来说同样无效。

所以我卡住了。

最佳答案

当我第一次在我的网站(.net 4.0 框架)中使用 LINQtoSQL(vb.net) 并将其推出到实时服务器时,我遇到了类似的问题。它在我的本地服务器上运行良好。

我所做的就是在我的 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>

它对我有用,值得一试我的 friend ......

关于vb.net - LinqDataSource 抛出 System.Data.Linq.Mapping.DataAttribute is not defined 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12089004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com