web.config 程序集元素和项目文件参考元素有什么区别 [英] What is difference between web.config assemblies element and project file Reference element

查看:18
本文介绍了web.config 程序集元素和项目文件参考元素有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看一个 asp.net 应用程序,我注意到在两个地方定义了程序集.在 web.config 中有 configuration/system.web/compilation/assemblies/add 元素.在项目文件中,在 Project/ItemGroup/Reference 元素下设置了引用.

I'm looking at an asp.net application, i notice that there are assemblies defined into two places. In web.config there is configuration/system.web/compilation/assemblies/add elements. In the project file there are references setup under the Project/ItemGroup/Reference elements.

我想知道,在任一位置添加的程序集/引用之间有什么区别?

I was wondering, what is the difference between assemblies/references added in either location?

推荐答案

在 web.config 部分:

In the web.config section:

assemblies 元素定义在 ASP.NET 应用程序编译期间使用的程序集名称的集合.

网站项目通常使用程序集元素,因为没有项目文件存储网站使用的引用位置.项目引用不适用于网站,因为它没有合适的项目文件来存储这些文件,因此必须将所有引用的程序集存储在 web.config 中.在这里有一些有趣的讨论,尽管没有直接相关.

Web site projects usually use the assemblies element as there is no project file storing location of references that the web site uses. 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. There is some interesting, although not directly related, discussion here.

Web 应用程序项目可以同时使用程序集元素和项目引用.

Web application projects may make use of both the assemblies element and project references.

在程序集元素中引用还意味着您不必在使用该命名空间的任何 .aspx 页面的顶部添加 @register.在此处有更多讨论.

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. More discussion on that here.

这篇关于web.config 程序集元素和项目文件参考元素有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆