O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Assemblies and VB.NET

To a VB.NET programmer, an assembly is similar to a traditional DLL or EXE file, except that it contains additional information, such as reference and type information (which in COM was often contained in a separate OLB or TLB file, called a type library). When a VB.NET application is compiled, the compiler creates an assembly for the target EXE or DLL.

In the .NET environment, namespaces are part of assemblies. An assembly can contain many namespaces, and namespaces can be nested.

For instance, the System namespace is the fundamental namespace in the .NET environment. This is not the time to go into details, but one example will be useful. The System namespace identifies the Array class (Microsoft likes to say that the namespace contains classes.) One of the members of the Array class is the Copy method, which copies a portion of one array to another array. Thus, we can write code such as the following:

Imports System     ' Optional since System is always imported
Dim array1(  ) As Integer = {1, 2, 3, 4}
Dim array2(3) As Integer
Array.Copy(array1, array2, 3)

To use an existing assembly in a VB.NET project, you must do two things:

  • Add a reference to the assembly to your project. There are two exceptions to this rule, however. A reference to the assembly containing the System namespace (mscorlib.dll) is added automatically, as is a reference to the assembly containing the language being used (for VB.NET, this is Microsoft.VisualBasic.dll).

  • Access the member or members ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required