Exforsys

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor

Ads


Home arrow Technical Training arrow VB.NET 2005

.NET Assemblies Page - 3

Page 3 of 3
Author : Exforsys Inc.     Published on: 7th Jul 2005    |   Last Updated on: 24th Dec 2007

.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.



 
This tutorial is part of a VB.NET 2005 tutorial series. Read it from the beginning and learn yourself.

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor
 

Comments

 

Share


Connect

Related Articles

Exforsys e-Newsletter

Enhance Technical and Soft Skills every week, get our Job Interview Questions and Answers eBook free when you subscribe.

Subscribe and Get Free Bonus PDF Book

eBook

Subscribe