How to perform Assembly building in VB.NET

In this article I will show you the assembly building using VB.NET.
  • 1533

For assembly building you have to use the .NET compiler and compiler having this four element which performed in assembly building.

  1. Friendly name

  2. Culture setting

  3. Version number

  4. Public key or public key token

Friendly name: you can use like MyAssembly.

Culture setting: This phase is all about the representation mean the culture setting shows the spoken language in which the assembly has localized.

Version number: It shows the version of assembly in which it was created and the version number shows in the four parts with . separation like this four parts have own different meaning: it represents the major version, minor version, build number, and revision number, and this version number you should be declared at the time of assembly creation at the top of the project source files.

Syntax of declaration of version number

Import System.Reflection
<Assembly: AssemblyVersion ("major version.minor number.revision number")>

If you not specify any version number the compiler per perform this task and then the version number will be this is default version number.

Public key or public key token: Public key is represents your identification, ones you used a public key then the same public key is not used by any other person it is unique key. The public key is stored in key file as binary format a size of 128 bytes.

You can also write the public key by using a text based hexadecimal format as below:


Figure 1

The public key is smaller in size only 8 byte value, So we used public key token at the place of public key it is almost same as public key the only difference is that the public key token is represented by a 16-character hexadecimal string value.

Get to Work of Assembly Building.

The first step of assembly building is to give a strong name to the assembly which get a pair of public-private key pair. The public key is written into the physical image of the assembly. The private key is used to generate digital signatures. The key is generated using the .NET framework strong name utility, SN.exe, by specifying the â€"k switch and the target key file from the command line.

SN.exe -K Keyfilename.snk

The next step is to add the following code at the top of one of the source files in a project:

Import System.Reflection

When you built the project, an assembly with a strong name is generated.


More Articles

© 2020 DotNetHeaven. All rights reserved.