Linq to sql 共享主机上的Linq 2 SQL
我最近在共享主机上遇到了与linq的问题。Linq to sql 共享主机上的Linq 2 SQL,linq-to-sql,hosting,shared,Linq To Sql,Hosting,Shared,我最近在共享主机上遇到了与linq的问题。 主机是Shared Intelligent,它们支持框架的v3.5。但是,我不确定他们是否安装了SP1。我怀疑他们没有 我有一个简单的News表,其结构如下: NewsID uniqueidentifier Title nvarchar(250) Introduction nvarchar(1000) Article ntext DateEntered datetime (defaul
主机是Shared Intelligent,它们支持框架的v3.5。但是,我不确定他们是否安装了SP1。我怀疑他们没有 我有一个简单的
News
表,其结构如下:
NewsID uniqueidentifier
Title nvarchar(250)
Introduction nvarchar(1000)
Article ntext
DateEntered datetime (default getdate())
IsPublic bit (default true)
我的目标是显示此表中最近的3条记录。我最初使用D&D方法(我知道,我知道),创建了一个linq数据源,但无法找到一种方法来限制结果,因此我删除了该方法,并编写了以下内容:
var dc = new NewsDataContext();
var news = from a in dc.News
where a.IsPublic == true
orderby a.DateEntered descending
select new { a.NewsID, a.Introduction };
lstNews.DataSource = news.Take(3);
lstNews.DataBind();
这在我本地的机器上运行得很好
但是,当我将所有内容上载到共享主机时,我收到以下错误:
.Read_<>f__AnonymousType0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1<System.Data.SqlClient.SqlDataReader>)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MethodAccessException:
.Read_<>f__AnonymousType0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1<System.Data.SqlClient.SqlDataReader>)
。读取\u f\u匿名类型0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1)
描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源。
异常详细信息:System.MethodAccessException:
.Read_f__匿名类型0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1)
我试图在谷歌上搜索错误,但没有成功。然后,我尝试以我能想象的任何方式修改我的查询,删除where/orderby参数的各种组合,并将我的查询限制为单个列,甚至删除Take命令
因此,我的问题分为三个部分:
System.MethodAccessException
在框架缺少程序集或其中一个引用的版本错误时引发
我要做的第一件事是尝试将代码上传并引用到BIN中的LINQ程序集,而不是共享主机提供商GAC