简体   繁体   English

在web.config和项目引用根目录中引用程序集的区别?

[英]Difference in referencing an assembly in web.config and project reference root?

I am building this project and i have an external dll . 我正在建立这个项目,并且我有一个外部dll。 I want to add a reference to it from the root reference folder . 我想从根引用文件夹添加对它的引用。 I have not tried though if its wrong. 我没有尝试过,如果它是错误的。 But there is an obvious answer to this question across internet stating i have to referenc e the dll in the web.config assembly file . 但是整个互联网上都有一个明显的答案,表明我必须引用web.config程序集文件中的dll。

I want to know why do we need to do so? 我想知道为什么我们需要这样做?

what is the differences between both ways ? 两种方式有什么区别?

in the web.config section 在web.config部分

The assemblies element defines a collection of assembly names that are used during compilation of an ASP.NET application. Assembly元素定义了在ASP.NET应用程序的编译过程中使用的程序集名称的集合。

The assemblies element us usually used in web site projects as there is no project file storing location of references that the web site uses. 我们通常在网站项目中使用的Assemblys元素,因为没有项目文件存储网站使用的引用的位置。 The project references would not apply to a web site, as it has no proper project file to store these in, so must store all referenced assemblies in the web.config. 项目引用不适用于网站,因为它没有适当的项目文件来存储这些项目,因此必须将所有引用的程序集存储在web.config中。 There is some interesting, although not directly related, discussion here . 尽管这里没有直接相关的讨论,但有一些有趣的讨论。 In a web application project you can use both the assemblies element and project references. 在Web应用程序项目中,可以同时使用Assembly元素和项目引用。

Having a reference in the assemblies element also means you won't have to add the @register at the top of any .aspx pages that use that namespace. 在Assemblys元素中具有引用也意味着您不必在使用该命名空间的任何.aspx页的顶部添加@register。 More discussion on that here . 这里有更多讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM