ASP.NET-bin目录与在web.conf中添加程序集 [英] ASP.NET - bin Directory vs. Adding Assembly in web.conf

查看:65
本文介绍了ASP.NET-bin目录与在web.conf中添加程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于ASP.NET编程,我是一个相对较新的人(但一般而言不是编程人员),并且我一直在寻找一个已经交到我手中的项目.在这个项目中,有一个bin目录,其中包含许多DLL文件.

I am relatively new to ASP.NET programming (but not programming in general), and I have been looking through a project that has been handed off to me. Within this project, there is a bin directory which contains a slew of various DLL files.

然后,在web.conf文件中的程序集结构内(在XML内),添加了许多其他程序集.

Then, in the web.conf file, inside the assemblies structure (within the XML), there is a slew of other assemblies being added.

我通常都在SO上以及通过Google进行搜索,但我仍在为两者之间的差异而苦苦挣扎.一种方法比另一种更好"吗?我们将不胜感激.

I've done a search on both SO and through Google in general, and I am still struggling over what the difference is between the two. Is one way "better" than the other? Any clarification that can be provided would be most appreciated.

谢谢.

推荐答案

在ASP.NET应用程序中有几种引用程序集(通常是DLL)的方法:

There are several ways to reference assemblies (DLLs, usually) in an ASP.NET application:

  1. 将DLL添加到应用程序的"bin"目录中.这将在应用程序的每个代码文件和ASPX文件中创建对该DLL的隐式引用.这意味着App_Code中ASPX文件内或CS文件内的代码可以使用该DLL中的类型.

  1. Add the DLL to your application's "bin" directory. This creates an implicit reference in every code file and ASPX file in your application to that DLL. This means that code inside an ASPX file or inside a CS file in App_Code can use the types in that DLL.

在web.config的<assemblies>部分中添加对DLL的引用.有关语法的详细信息,请参见 MSDN .通常,有多个适用于特定Web应用程序的web.config文件.应用程序本身可以具有多个web.config文件(例如,特定文件夹中的web.config可能会添加其自己的引用).还有一个全局的web.config(或machine.config),该引用具有可用于计算机上所有ASP.NET应用程序的引用.

Add a reference to the DLL in the <assemblies> section in web.config. See MSDN for details on the syntax. There are generally multiple web.config files that apply to a particular web application. The application itself can have several web.config files (for example, a web.config in a particular folder might add its own references). There is also a global web.config (or machine.config) that has references available to all ASP.NET applications on the computer.

在特定的ASPX(或ASCX或MASTER)文件中使用<%@ Assembly Name="" %>指令.有关语法的详细信息,请参见 MSDN .

Use the <%@ Assembly Name="" %> directive in a particular ASPX (or ASCX or MASTER) file. See MSDN for details on the syntax.

ASP.NET应用程序中给定文件中的引用是上述适用项的组合.

The references in a given file in an ASP.NET application is a combination of the applicable items above.

您必须引用程序集的原因是ASPX文件(非常类似于CS和VB文件本身)最终会由C#或VB编译器进行编译.为了使这些编译器知道您要使用的类型,他们需要知道哪些程序集包含这些类型.

The reason you have to reference assemblies is that ASPX files (much like CS and VB files themselves) eventually get compiled by either the C# or VB compiler. In order for those compilers to know what types you want to use they need to know which assemblies contain those types.

这篇关于ASP.NET-bin目录与在web.conf中添加程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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