Technical Training
VB.NET 2005.NET Assemblies Page - 3
.NET Assemblies
.
.
.
Ads
Compiling Satellite Assemblies With Strong Names
To install satellite assemblies into the global cache they must have strong names. Strong-named assemblies are signed with a valid public/private key pair.
When an application is being developed it is likely that the developer does not have access to the final public/private key pair. In order to install a satellite assembly in the global assembly cache and ensure that it works as expected, the technique called delayed signing is used. Delay sign an assembly implies that a space in the file is reserved for the strong name signature at build time. The actual signing is delayed until a later date when the final public/private key pair is available.
Obtaining the Public Key
To delay sign an assembly, the developer must have access to the public key. Public keys can be obtained from the organization that will do the eventual signing or a public key can be created using the Strong Name Tool(Sn.exe)
The following Sn.exe command creates a test public/private key pair and saves it in the file TestKeyPair.snk. The –k option specifies to Sn.exe to create a new key pair and save it in the specified file.
sn –k TestKeyPair.snk
The public key can be extracted from the file containing the test key pair. The following command extracts the public key from TestKeyPair.snk and saves it in PublicKey.snk.
sn –p TestKeyPair.snk PublicKey.snk
Delay Signing an Assembly
Once the developer has obtained or created the public key, the Assembly Linker (Al.exe) can be used to compile the assembly and specify delayed signing.
The following Al.exe command creates a strong-named satellite assembly for the application MyApp from the strings.ja.resources file.
al /t:lib /embed:strings.ja.resources /culture:ja /out:MyApp.resources.dll /delay+ /keyfile:PublicKey.snk
The /delay+ option specifies to delay sign the assembly. The /keyfile: option specifies the name of the key file containing the public key to use to delay sign the assembly.
Re-signing an Assembly
At some later date, a delay-signed satellite assembly must be re-signed with the real key pair. This can be done using Sn.exe.
The following Sn.exe command signs MyApp.resources.dll with the real key pair stored in the file RealKeyPair.snk. The –R option specifies to Sn.exe to re-sign a previously signed or delay-signed assembly.
sn –R MyApp.resources.dll RealKeyPair.snk
Installing a Satellite Assembly in the Global Assembly Cache
A satellite assembly that has been compiled with a strong name is ready to install in the global assembly cache. The assemblies can be installed into the cache using the Global Assembly Cache Tool (Gacutil.exe).
The following Gacutil.exe command installs MyApp.resources.dll into the global assembly cache.
gacutil /i:MyApp.resources.dll
The /i option specifies to Gacutil.exe to install the specified assembly into the global assembly cache. As a result of this command, an entry is placed in the cache, which allows entries in this .resources file to be accessed. After being installed in the cache, the specified resource is available to all applications that are designed to use it.
All compiled satellite assemblies have the same name. They are differentiated at runtime based upon the culture specified at compile time in Al exe’s /Culture option and the directory location of the assembly. The satellite assemblies can be placed in expected directory locations..
Resources in Applications
Nearly every production-quality application needs to use resources. A resource is any non-executable data that is logically deployed with an application. A resource might be displayed in an application as error messages or as part of the user interface. Resources can contain data in a number of forms, including strings, images, and persisted objects. Storing your data in a resource file allows you to change the data without recompiling your entire application. Note that to write persisted objects to a resource file, the objects must be serializable.
The .NET Framework provides comprehensive support for the creation and localization of resources. In addition, the .NET Framework supports a simple model for packaging and deploying these localized resources.
Ads
Creating and Localizing Resources
The application's resources can be localized for specific cultures. This allows the developer build localized (translated) versions of the application. An application loads the appropriate localized resources based on the value of the CultureInfo.CurrentUICulture property. This value is set either explicitly in the application's code or by the common language runtime based on the locale for the current user on the local computer.
Packaging and Deploying Resources
The application's resources can be deployed in satellite assemblies. By definition, satellite assemblies only contain resource files. They do not contain any application code. In the satellite assembly deployment model, the developer can create an application with one default assembly (which is the main assembly) and several satellite assemblies. A satellite assembly should be created for each culture that the application supports. Because the satellite assemblies are not part of the main assembly, the developer can easily replace or update resources corresponding to a specific culture without replacing the application's main assembly.
It is important to determine which resources will make up the application's default resource assembly as it is a part of the main assembly. Any changes to it will compel the replacement of the main assembly. If a default resource is not provided for, an exception will be thrown when the resource fallback process attempts to find it. In a well-designed application, using resources should never throw an exception.
In this lesson we have studied in great detail the process of creating and using components and assemblies in VB.NET. In the lessons that follow we shall focus upon Data Binding.
VB.NET 2005
- VB.NET 2005 Free Training
- The .NET Framework Architecture Part 1
- The .NET Framework Architecture Part 2
- Application Class and Message Class
- Implementing Class Library Object
- Visual Studio.NET Namespaces
- .NET Assemblies
- Differences between VB.NET 1.0 and VB.NET 2.0
- Introducing VB.NET Windows Forms
- Visual Studio Windows Forms Designer
- Exploring the Forms Designer generated code
- Setting and Adding Properties to Windows Form
- Implementing Inheritance
- Event Handling In Visual Basic .NET
- Building Graphical Interface elements
- .NET Common Windows Forms Controls Part 1
- .NET Common Windows Forms Controls Part 2
- Common Controls and Handling Control Events
- DomainUpDown and NumericUpDown Controls
- Dialog Boxes in Visual Basic .NET
- Visual Studio Adding Controls to Windows Form
- VB.NET Validation Controls
- Working with Menu Controls
- VB.NET MDI Applications
- .NET Exceptions
- VB.NET Creating and Managing Components Part 1
- VB.NET Creating and Managing Components Part 2
- Simple Data Binding
- .NET Complex Data Binding
- .NET Data Form Wizard
- Data Manipulation with ADO.NET
- SQL Server Stored Procedures
- SQL Server Ad Hoc Queries
- Finding and Sorting Data in DataSets
- ADO.NET Object Model
- Working with DataSets
- Using XML Data
- Working with File System in .NET
- Creating Web Service
- Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
- Web Reference and Web Services
- Web Services - SOAP, WSDL, Disco and UDDI
- Web Application Testing in VB.NET 2005
- Web Application Tracing and Debugging
- Working with Legacy Code and COM Components
- ActiveX Controls and Legacy Code
- Windows Application Testing
- VB.NET Windows Application Testing
- Tracing VB.NET Windows Application
- Debugging Windows Applications In Visual Studio.NET 2005
- Deploying Windows Applications In Visual Studio.NET 2005
- Customizing Setup Project in Visual Studio.NET 2005
- Shared Assembly
- Microsoft .NET Creating Installation Components
- The Registry Editor in Visual Studio.NET 2005
- The File Types Editor







