Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Assemblies and the Global Assembly Cache (C# and Visual Basic)

Assemblies form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions for a .NET-based application. Assemblies take the form of an executable (.exe) file or dynamic link library (.dll) file, and are the building blocks of the .NET Framework. They provide the common language runtime with the information it needs to be aware of type implementations. You can think of an assembly as a collection of types and resources that form a logical unit of functionality and are built to work together.

Assemblies can contain one or more modules. For example, larger projects may be planned in such a way that several individual developers work on separate modules, all coming together to create a single assembly. For more information about modules, see the topic How to: Build a Multifile Assembly.

Assemblies have the following properties:

  • Assemblies are implemented as .exe or .dll files.

  • You can share an assembly between applications by putting it in the global assembly cache. Assemblies must be strong-named before they can be included in the global assembly cache. For more information, see Strong-Named Assemblies.

  • Assemblies are only loaded into memory if they are required. If they are not used, they are not loaded. This means that assemblies can be an efficient way to manage resources in larger projects.

  • You can programmatically obtain information about an assembly by using reflection. For more information, see Reflection.

  • If you want to load an assembly only to inspect it, use a method such as ReflectionOnlyLoadFrom.

Within every assembly is an assembly manifest. Similar to a table of contents, the assembly manifest contains the following:

  • The assembly's identity (its name and version).

  • A file table describing all the other files that make up the assembly, for example, any other assemblies you created that your .exe or .dll file relies on, or even bitmap or Readme files.

  • An assembly reference list, which is a list of all external dependencies—.dlls or other files your application needs that may have been created by someone else. Assembly references contain references to both global and private objects. Global objects reside in the global assembly cache, an area available to other applications, somewhat like the System32 directory. The Microsoft.VisualBasic namespace is an example of an assembly in the global assembly cache. Private objects must be in a directory at either the same level as or below the directory in which your application is installed.

Because assemblies contain information about content, versioning, and dependencies, the applications you create with Visual Basic and C# do not rely on registry values to function properly. Assemblies reduce .dll conflicts and make your applications more reliable and easier to deploy. In many cases, you can install a .NET-based application simply by copying its files to the target computer.

For more information see Assembly Manifest.

To use an assembly, you must add a reference to it, as described in How to: Add or Remove References By Using the Add Reference Dialog Box. Next, you use the Imports statement in Visual Basic or using directive in C# to choose the namespace of the items you want to use. Once an assembly is referenced and imported, all the accessible classes, properties, methods, and other members of its namespaces are available to your application as if their code were part of your source file.

In C#, you can also use two versions of the same assembly in a single application. For more information, see extern alias.

Compile your application by clicking Build on the Build menu or by building it from the command line using the command-line compiler. For details about building assemblies from the command line, see Building from the Command Line (Visual Basic) for Visual Basic and Command-line Building With csc.exe for C#.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft