I have an ASP.NET page A that uses a data layer assembly DAL. I reference the DAL assembly with a<%@ Assembly Name="NGC.DAL" %>
tag since there is no project to add the reference to. The assembly itself I copied to the pages' bin folder.
我有一个使用数据层程序集DAL的ASP.NET页面A.我使用<%@ Assembly Name =“NGC.DAL”%>标记引用DAL程序集,因为没有要添加引用的项目。组件本身我复制到页面的bin文件夹。
The assembly DAL is a project that references System
and System.Data
.
程序集DAL是一个引用System和System.Data的项目。
Now when A calls a method in DAL, the compiler gives the error
现在当A在DAL中调用方法时,编译器会给出错误
BC30652: Reference required to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes' containing the type 'System.Data.IDbConnection'. Add one to your project.
BC30652:程序集'System.Data,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 969db8053d3322ac,Retargetable = Yes'所需的引用,包含类型'System.Data.IDbConnection'。在项目中添加一个。
I tried referencing the assembly System.Data
with a <%@Import Namespace="System.Data" %>
tag and I tried copying it to the bin folder and referencing it with a<%@ Assembly Name="System.Data" %>
tag, both in A directly. Nothing worked.
我尝试使用<%@ Import Namespace =“System.Data”%>标记引用程序集System.Data,我尝试将其复制到bin文件夹并使用<%@ Assembly Name =“System.Data”%引用它>标签,都在A中直接。没有任何效果。
Why would a project A that uses project B which uses project C require a reference to B and C rather than just B and why does the way above not work?
为什么使用项目B的项目A使用项目C需要引用B和C而不仅仅是B,为什么上面的方法不起作用?
This MSDN thread covers the problem but shows no solution that works.
此MSDN线程涵盖了该问题,但没有显示有效的解决方案。
EDIT: As Robert Wagner suggested I added the reference to the web.config. Now I get another error message. BC30560: 'CommandBehavior' is ambiguous in the namespace 'System.Data'. which is odd because the one in the web.config is the only one I reference inside the page.
编辑:正如Robert Wagner建议我添加了对web.config的引用。现在我收到另一条错误消息。 BC30560:'CommandBehavior'在名称空间'System.Data'中不明确。这很奇怪,因为web.config中的那个是我在页面中引用的唯一一个。
Maybe it's worth mentioning that the System.Data
referenced and used in the DAL assembly is from the compact framework. But since it's the only one I use, where does the ambiguity come from?
也许值得一提的是,在DAL程序集中引用和使用的System.Data来自紧凑框架。但由于它是我使用的唯一一个,模糊性来自哪里?
1 个解决方案
#1
Most likely you have inherited from a System.Data class in your DAL dll and are using that class in your website. It requires a reference to be able to resolve the references those classes otherwise the compiler would not know what the class contract is.
您很可能从DAL dll中的System.Data类继承并在您的网站中使用该类。它需要一个引用才能解析引用这些类,否则编译器将不知道类合同是什么。
You should not need to copy in System.Data as it is in the GAC.
您不需要像在GAC中那样复制System.Data。
A better way would be to add the reference in your web.config file:
更好的方法是在web.config文件中添加引用:
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
</system.web>
When you say "there is no project to add references to" are you using Visual Studio? If so, why not use the Web Application or Web Site projects?
当您说“没有项目要添加引用”时,您使用的是Visual Studio吗?如果是这样,为什么不使用Web应用程序或Web站点项目?
#1
Most likely you have inherited from a System.Data class in your DAL dll and are using that class in your website. It requires a reference to be able to resolve the references those classes otherwise the compiler would not know what the class contract is.
您很可能从DAL dll中的System.Data类继承并在您的网站中使用该类。它需要一个引用才能解析引用这些类,否则编译器将不知道类合同是什么。
You should not need to copy in System.Data as it is in the GAC.
您不需要像在GAC中那样复制System.Data。
A better way would be to add the reference in your web.config file:
更好的方法是在web.config文件中添加引用:
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
</system.web>
When you say "there is no project to add references to" are you using Visual Studio? If so, why not use the Web Application or Web Site projects?
当您说“没有项目要添加引用”时,您使用的是Visual Studio吗?如果是这样,为什么不使用Web应用程序或Web站点项目?