Assemblies

Assemblies

The assembly is the building block of a VB.NET application. Basically, an assembly is a collection of the types and resources that are built together to provide functionality to an application.

· Assemblies look like dynamic link libraries (.dll) or executable programs (.exe).
· Differ from .exe and .dll files in that they contain the information found in a type library plus the information about everything else needed to use an application or component.
· Includes a mix of Microsoft Intermediate Language (IL) and machine code.
· Invokes the CLR by machine code found in the first several bytes of an assembly file.
· Contains one or more files.
· An application can be composed of one or more assemblies.
· An assembly can be a single portable executable (PE) file (like an .exe or .dll) or multiple PE files and other external resource files such as bitmap files.

Assemblies store metadata (data about the application) and include:

§ Information for each public class or type used in the assembly – information includes class or type names, the classes from which an individual class is derived, etc.
§ Information on all public methods in each class – includes the method name and any return values.
§ Information on every public parameter for each method – includes the parameter name and type.
§ Information on public enumerations including names and values.
§ Information on the assembly version (each assembly has a specific version number).
§ Intermediate language code to execute.
§ Required resources such as pictures, assembly metadata – also called the assembly manifest (the assembly title, description, version information, etc).

Multiple versions of an assembly can run simultaneously on the same client computer. This aids with compatibility with previous versions.

Assemblies shared by multiple applications on a client computer can be installed into the global assembly cache of Windows – this enhances security because only users with Administrator privileges on the machine can delete from the global assembly cache.

Strong-Named Assemblies

The strong-named assembly concept is used to guarantee the uniqueness of an assembly name – unique names are generated with the use of public and private key pairs when an assembly is compiled.

Applications can generally only run with the assembly version with which they are originally compiled. In order to update a component (such as a DLL for a control you’ve created), a publisher policy file is used to redirect an assembly binding request to a new version.

The .NET framework checks the integrity of strong-named assemblies to ensure they have not been modified since they were last built. This prevents unauthorized modification before loading.

The .NET framework creates a strong-named assembly by combining the assembly identify (name, version, and culture information) with a public key and digital signature.

As the programmer, you must generate the strong name key file (.snk filename extension) that contains the public-private key pair by using the Strong Name (Sn.Exe) utility or Visual Basic.NET IDE (this latter choice is usually the approach taken – simply involves clicking the right block during the building of an assembly). In fact, a project’s property page has a Strong Name section to automatically generate a strong name key file to add to a project. The public key is inserted into an assembly at compile time. The private key is used to sign the assembly.

Versioning Strong-Named Assemblies

This shows an example publisher policy file written in XML. This file would be compiled for shipment with a new component version using the Assembly Generation tool (Al.Exe). This signs the assembly with the strong name used originally with the first version in order to confirm that the new component is from a valid source.

(configuration)
(runtime)
(assemblyBinding)
(dependentAssembly)
(assemblyIdentity name = “myassembly”
publicKeyTokey=”ba76ce45677f9cd6″
culture=”en-us”/)
(bindingRedirect
oldVersion=”1.0.0.0″
newVersion=”2.0.0.0″/)
(codeBase version=”2.0.0.0″
href=http://www.fh.ora2003.edu/Test.dll/)
(/dependentAssembly)
(/assemblyBinding)
(/runtime)
(/configuration)

Ooops 😦 i was unable to write less than sign and greater than sign in this blog so i had to use
( – less than sign
) – greater than sign.

The publicKeyTokey attribute is a hexadecimal value that identifies the strong name of the assembly.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: