ASP.NET Website's BIN directory and references

不打扰是莪最后的温柔 提交于 2019-12-31 02:23:20

问题


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.


回答1:


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.




回答2:


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.




回答3:


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!



来源:https://stackoverflow.com/questions/378350/asp-net-websites-bin-directory-and-references

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!