梓囚徒貧圭�鮗� ○ 賜 ★ 辛酔堀貧和鍬匈��梓囚徒貧議 Enter 囚辛指欺云慕朕村匈��梓囚徒貧圭�鮗� ● 辛指欺云匈競何��
!!!!隆堋響頼��紗秘慕禰厮宴和肝写偬堋響��
' Review the values of the assembly attributes
'The following GUID is for the ID of the typelib if this project is exposed to
' Version information for an assembly consists of the following four values�此�
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown here�此�
'
Notice that all of the assembly descriptors are declared as attributes。 The bolded
attributes reference the version of the assembly。 By adjusting these attributes�察�you can tweak
which assembly is loaded�察�as explained in more detail in the uping ^Versioning Assemblies ̄
section。
To load a specific assembly�察�you need to create an assembly name�察�like this�此�
Dim assemblyName As AssemblyName = New AssemblyName��value��
Dim assembly As Assembly = Assembly。Load��assemblyName��
Dim obj As Object = assembly。CreateInstance��info。TypeName��
The variable value contains the precise identifier of the assembly and is passed as a
constructor parameter to AssemblyName。 The resulting AssemblyName instance is passed to the
method Assembly。Load�┌��察�which loads the assembly。 The instantiation of the type follows the
same sequence as previously outlined。
Note that there is no indication of where the assembly is located。 The default locations that
are probed are the local working directory of the executing process and the GAC。
´´´´´´´´´´´´´´´´´´´´´´Page 355´´´´´´´´´´´´´´´´´´´´´´´
CH AP T E R 1 2 * L E AR N IN G AB O U T AP P L I CAT I ON CO N F IG U R AT IO N A N D D Y N A M IC L O AD IN G 333
*Note For more details about assembly loading�察�see Pro VB 2008 and the 3。5 Platform�察�Third Edition
by Andrew Troelsen ��Apress�察�2008��。
Relocating a Strongly Named Assembly to the GAC
Besides having the ability to tweak which assembly is loaded�察�another reason to use the precise
assembly name is to have the ability to load an assembly from the GAC。 The GAC is a place where
assemblies can be placed to have global shared access。 Think of the GAC as the WindowsSystem32
directory of the environment。 The precise location for the GAC is c��windowsassembly。
Even though the GAC is just another directory�察�you should not just delete and add assemblies
there�察�as you would with any other directory。 To delete a file from the GAC�察�use the context
sensitive Uninstall menu item ��in Windows Explorer right´click the assembly you want to
uninstall and select Uninstall��。
To add an assembly to the GAC�察�use the utility gacutil�察�which is distributed with the
SDK ��not with Visual Basic Express��。 You can locate it at C��Program FilesMicrosoft SDKs
Windowsv6。0Bin or similar。 Add this directory to your path so that you can run gacutil anywhere。
The following mand lines demonstrate how to add the Definitions and
Implementations2 assemblies to the GAC ��assuming the files implementations2。dll and
definitions。dll reside in the current directory��。
gacutil /I definitions。dll
gacutil /I implementations2。dll
Remember to add Definitions�察�because Implementations2 depends on Definitions。
Failing to add Definitions will generate gacutil errors。
ORGANIZING DYNAMIC CODE
If you are going to place files in the GAC�察�don¨t use the techniques demonstrated in this book when doing a
production release。 The techniques discussed in this book are meant for developers�察�and only developers。 The
techniques are shortcuts that assume you know what the dependencies are and are aware of what you are
doing。 For distribution purposes�察�use the Microsoft Windows Installer application to install files into the GAC。
When writing dynamic code�察�the idea is to separate and pletely partmentalize the development
of the ponent and the caller of the ponent。 Thus�察�you should not develop both pieces in the same
project。 Create separate projects and have them working with test routines。 Then�察�at runtime�察�bine the
functionalities�察�and everything should work ��that is�察�if you properly tested your code��。
Using Version Numbers
Version numbers are a way of being able to control the features and robustness of an applica
tion。 In the packaged software market�察�the concept of the version number has nearly disappeared。
For example�察�consider Microsoft¨s operating system versions�此�Windows 95�察�Window 98�察 �
Windows XP�察�Windows 2000�察�Windows Vista�察�and so on。
´´´´´´´´´´´´´´´´´´´´´´Page 356´´´´´´´´´´´´´´´´´´´´´´´
334 CH AP T E R 1 2 * L E A R N I N G A B OU T A PP L I CA TI O N CO N F I G U R AT IO N AN D D Y N A M I C L O AD I N G
In open source software�察�version numbers are used extensively and are considered very
important。 Yes�察�the version numbers resemble a lottery ticket�察�but they do follow a convention。
Understanding the convention makes it easier to select open source packages。 And more
important�察�applying this versioning strategy makes it simpler to understand your assemblies。
Understanding Version Numbers
Let¨s say you want to download the open source program Capivara ��a Java file manager and
synchronization program��。 You see the version number 0。8。3。 The version number contains
three parts�此�
Major number�此�The major number is 0 in the example。 If the software has not reached the
number 1�察�the version is considered a beta。 But often�察�a beta identifier does not mean
the version is unusable。 Changing the major version number indicates a major change
of functionality。 This means what worked in version 1 may not work with version 2。 An
example is the Apache HTTPD server project�察�where the 1。x and 2。x series are two different
implementations。
Minor number�此�The minor number is 8 in the example。 It is used to define minor function
ality changes in a piece of software。 Changing the minor number ��such as 7 to 8�� indicates
new features�察�but old functionality is supported。 A change may include bug fixes or patches。
Patch number�此�The path number is 3 in the example。 It is used to define a patched version
of the software that has bug fixes or other changes。 The changes do not include features�察 �
and the functionality does not change。
When you attempt to download an open source package�察�you are typically confronted with
multiple versions。 For example�察�you might see the version numbers 4。23 and 4。29 ��beta��。 Because
most people want the latest and greatest�察�they might be tempted to download 4。29。 But remember
that open source projects make multiple versions available。 In the example�察�you should down
load version