views:

1924

answers:

1

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.

The assembly DAL is a project that references System and System.Data.

Now when A calls a method in DAL, the compiler gives the error

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.

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.

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?

This MSDN thread covers the problem but shows no solution that works.

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.

Maybe it's worth mentioning that the System.Data referenced and used in the DAL assembly is from the compact framwork. But since it's the only one I use, where does the ambiguity come from?

+2  A: 

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.

You should not need to copy in System.Data as it is in the GAC.

A better way would be to add the reference in your web.config file:

 <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?

Robert Wagner