TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P21

Professional 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 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 . For example we could use the Import directive specifying the namespace attribute for the namespace @ Import namespace If we include this directive in the file for our web application we can use classes in without the need to fully qualify the class name. For example if we use the DataSet class we can refer to it as fully qualified class name or use the Import directive naming the 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 and when we used them. Assembly - This directive is used to name assemblies containing classes we wish to use within our 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 application. The Import and Assembly directives are very different. Import assumes that the assembly for example .

19    16    0
182    13    0
138    6    0
3    7    0
142    12    0