Vous êtes sur la page 1sur 1

ASSEMBLIES

What are Assemblies?


Assemblies are the building blocks of .NET Framework They form the fundamental unit of deployment,
version control, reuse, activation scoping, and security permissions.
An assembly is a collection of types and resources that are built to work together and form a logical unit of
functionality.
What are Assemblies?
An assembly provides the common language runtime with the information it needs to be aware of type
implementations.
To the runtime, a type does not exist outside the context of an assembly.

Put simply, as assembly is a project that compiles to an EXE or to a DLL file.


Assembly Benefits
Assemblies are designed to simplify application deployment and to solve versioning problems that can
occur with component-based applications. Because they are self-describing components that have no
dependencies on registry entries, assemblies enable zero-impact application installation.
Parts of an Assembly
The assembly manifest, or metadata. This contains information about the assembly that is exposed to the
CLR. The type metadata, which exposes information about the types contained within the assembly.
The IL code for your assembly. The resource files, which are nonexecutable bits of data, such as strings
or images for a specific culture.
Assembly Manifest
Identity: Contains the name and version number of the assembly, and can contain optional information
such as locale and signature information.
Types and resources: Contains a list of all the types that will be exposed to the CLR, as well as
information about how those types can be accessed.
Assembly Manifest-2
Files: Contains a list of all files in the assembly, as well as dependency information for those files.
Security Permissions: Describes the security permissions required by the assembly. If the required
permissions conflict with the local security policy, the assembly will fail to execute.
Types of Assemblies
Assemblies can be either private or shared.
A private assembly is an assembly that is used by one application only.
It is integral to the application, packaged with the application, and available to only that application.
Hence, they do not have version or identity issues.
Shared Assemblies
Only one copy of shared assemblies is present per A shared assembly can be used by multiple
applications.
machine.
Multiple applications can reference and use a shared assembly.
You can share an assembly by installing it to the Global Assembly Cache (GAC).
Benefits of Shared Assemblies
Shared location: If multiple applications need to access the same copy of an assembly, it should be
shared.
Security: The GAC is located in the C:\WINNT folder, which are given the highest level of security by
default. Side-by-side versioning: Multiple versions of the same assembly can be installed to the GAC, and
applications can locate and use the appropriate one
Strong Naming
Sharing an assembly and installing it to the GAC further requires that your assembly be signed with a
strong name. A strong name is a name that guarantees an assembly identity. It consists of information the
assembly, such as its name, version number, any culture information, and the public key of a
public/private key pair.
Installing to the GAC
Generate a key pair with the strong name utility (sn.exe).
Sign your assembly with the strong name by specifying the path to the key file in the AssemblyKeyFile
attribute in the AssemblyInfo file of your project.
Install the assembly to the GAC using the GAC utility (gacutil.exe).

Vous aimerez peut-être aussi