views:

2742

answers:

4

Imagine the following solution: -Website ABC.com (not Web Application) -BLL (business logic layer in a seperate assembly) -DTO (dto objects in their own assembly) -DAL (data access layer in it's own assembly as well).

  1. The BLL has a reference to the DAL.
  2. The BLL has a reference to the DTO layer.
  3. The Website project references the BLL.

When one compiles the website project, the following DLLs will appear in the BIN directory: BLL.dll DTO.dll DAL.dll

When one goes to preview the site, an error occurs about not having the necessary assembly references... Now if one right clicks on the website project, Add Reference, and explicitly add the reference to the missing assemblies, it will work fine.

It seems to me like ASP.NET pulls the referenced assemblies of the referenced assembly being added/referenced in the website.

Why does one need to add explicit references to the references of the references... ? Sorry if I'm not wording this correctly or if it confusing.

Any answer or thoughts are appreciated.

A: 

I think the problem may have to do with using a web site project, as oppossed to a Web Application. I can't remember off the top of my head, but there's something funky about the way web site projects are compiled, as oppossed to web application projects.

Nathan Prather
+1  A: 

Here is a good article on your question Compilation and Deployment.

It has something to do with "WebSites" being compile at runtime. Hopefully the above article will answer your question.

Chuck Conway
A: 

Thanks.. I wonder what the correct approach is as far as referencing.. Should I always reference the assemblies a referenced assembly references? That doesn't make much sense to me... I'd imagine I could reference ValidationUtil.dll and IT's references are internal to it so I shouldn't need to reference those assemblies. but apparently that is what asp.net website compilation does...

Charles - I'll read through the link you provided.. thanks!

A: 

Just tested this scenario today for the project I'm on. You should be just fine just adding your assembly in Web.config as:

<compilation debug="true">
  <assemblies>
    <clear/>
    <add assembly="mscorlib"/>
    <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

    <add assembly="YourBLLLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  </assemblies>
</compilation>

Also your assemblies should stay in the famous ./bin folder of your web site's root. GL!