Đang chuẩn bị liên kết để tải về tài liệu:
Professional ASP.NET 1.0 Special Edition- P21
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Professional ASP.NET 1.0 Special Edition- P21:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | in Visual Basic .NET or Usingin C . It simply provides a reference to a namespace that contains classes we wish to make use of. To use the Import directive we must guarantee that the assembly in which the namespace exists is also available. If it is not an ASP.NET exception will occur when the application is run. Support for adding the assembly is done either through the Assembly directive or the compilers section of our configuration file configuration is covered in the next chapter . To reference assemblies that are not available we can use the Assembly directive outlined next. The Import directive requires a single attribute The Namespace attribute of Import is used to identify an assembly namespace for use in global.asax. For example we could use the Import directive specifying the namespace attribute for the System.Data namespace @ Import namespace System.Data If we include this directive in the global.asax file for our web application we can use classes in System.Data without the need to fully qualify the class name. For example if we use the DataSet class we can refer to it as System.Data.DataSet fully qualified class name or use the Import directive naming the System.Data namespace and refer to the class simply as DataSet. Using the Import directive and its Namespace attribute saves us from having to fully qualify the name of the class. However in the event that two namespaces share a common class name such as Math we can t use the Import directive. Instead we would have to fully qualify the names such as Simple.Math and Complex.Math when we used them. Assembly - This directive is used to name assemblies containing classes we wish to use within our ASP.NET application. An assembly which is a compiled unit of code in .NET with the extension .dll exists either in the global assembly cache covered in Chapter 23 or the bin directory of the ASP.NET application. The Import and Assembly directives are very different. Import assumes that the assembly for example .