ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡
VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ)-µÚ87²¿·Ö
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿! Èç¹û±¾ÊéûÓÐÔĶÁÍ꣬ÏëÏ´μÌÐø½Ó×ÅÔĶÁ£¬¿ÉʹÓÃÉÏ·½ "Êղص½ÎÒµÄä¯ÀÀÆ÷" ¹¦ÄÜ ºÍ "¼ÓÈëÊéÇ©" ¹¦ÄÜ£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡4¡£23£»¡¡because¡¡4¡£29¡¡is¡¡a¡¡beta¡¡that¡¡may¡¡or¡¡may¡¡not¡¡work¡£¡¡Version¡¡4¡£23¡¡is¡¡considered¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡stable¡¡and¡¡therefore¡¡usable¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡open¡¡source¡¡munity¡¡will¡¡often¡¡use¡¡the¡¡following¡¡terminology¡¡when¡¡releasing¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡software¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡Stable£º¡¡A¡¡version¡¡that¡¡can¡¡be¡¡used¡¡in¡¡a¡¡production¡¡environment¡¡and¡¡should¡¡not¡¡crash¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡¡¡Unstable£º¡¡A¡¡version¡¡that¡¡should¡¡not¡¡be¡¡used¡¡in¡¡production¡£¡¡It¡¡will¡¡probably¡¡work£»¡¡but¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡have¡¡some¡¡crashes¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡Nightly£º¡¡A¡¡version¡¡with¡¡all¡¡bets¡¡off£»¡¡meaning¡¡that¡¡the¡¡version¡¡may¡¡or¡¡may¡¡not¡¡work¡£¡¡The¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡reason¡¡for¡¡using¡¡a¡¡nightly¡¡build¡¡is¡¡to¡¡monitor¡¡progress¡¡and¡¡check¡¡specific¡¡issues¡£¡¡Such¡¡a¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡version¡¡is¡¡not¡¡intended¡¡for¡¡consumer¡¡consumption£»¡¡it¡¡is¡¡intended¡¡solely¡¡for¡¡developers¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡Alpha¡¡£º¡¡A¡¡version¡¡that¡¡demonstrates¡¡the¡¡concepts¡¡that¡¡will¡¡make¡¡up¡¡a¡¡future¡¡version¡¡of¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡software¡£¡¡However£»¡¡in¡¡alpha¡¡versions£»¡¡what¡¡was¡¡available¡¡one¡¡day¡¡might¡¡be¡¡gone¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡next¡¡day¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡357¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡335¡¡
Versioning¡¡Assemblies¡¡
¡¡assembly¡¡version¡¡numbers¡¡are¡¡different¡¡from¡¡those¡¡used¡¡for¡¡open¡¡source¡¡packages¡£¡¡The¡¡¡¡
following¡¡is¡¡an¡¡example¡¡of¡¡versioning¡¡an¡¡assembly¡£¡¡
¡¡
¡¡
¡¡¡¡¡¡¡¡¡¡The¡¡attributes¡¡AssemblyVersion¡¡and¡¡AssemblyFileVersion¡¡can¡¡be¡¡added¡¡anywhere¡¡in¡¡the¡¡¡¡
assembly¡¡or¡¡application¡£¡¡In¡¡Visual¡¡Basic¡¡Express£»¡¡most¡¡likely¡¡the¡¡attributes¡¡are¡¡added¡¡to¡¡the¡¡file¡¡¡¡
AssemblyInfo¡£vb¡£¡¡
¡¡¡¡¡¡¡¡¡¡The¡¡versions¡¡of¡¡the¡¡file¡¡have¡¡four¡¡significant¡¡parts¡£¡¡From¡¡left¡¡to¡¡right£»¡¡these¡¡are¡¡major¡¡¡¡
version£»¡¡minor¡¡version£»¡¡build¡¡number£»¡¡and¡¡revision¡£¡¡The¡¡build¡¡number¡¡can¡¡represent¡¡a¡¡daily¡¡¡¡
build¡¡number£»¡¡but¡¡this¡¡is¡¡not¡¡required¡£¡¡The¡¡revision¡¡identifier¡¡can¡¡represent¡¡a¡¡random¡¡number£»¡¡¡¡
but¡¡this¡¡is¡¡not¡¡required¡¡either¡£¡¡For¡¡my¡¡assemblies£»¡¡I¡¡use¡¡a¡¡revision¡¡number¡¡of¡¡0£»¡¡and¡¡consider¡¡the¡¡¡¡
build¡¡number¡¡as¡¡a¡¡patch¡¡number¡£¡¡
¡¡¡¡¡¡¡¡¡¡Visual¡¡Basic¡¡Express¡¡has¡¡a¡¡built¡in¡¡mechanism¡¡that¡¡automatically¡¡updates¡¡the¡¡build¡¡and¡¡¡¡
revision¡¡numbers¡£¡¡Here£»¡¡the¡¡asterisk¡¡represents¡¡the¡¡auto¡increment£º¡¡
¡¡
¡¡¡¡¡¡¡¡¡¡Alternatively£»¡¡you¡¡can¡¡use¡¡a¡¡versioning¡¡tool£»¡¡or¡¡you¡¡can¡¡increment¡¡the¡¡numbers¡¡manually¡£¡¡¡¡
The¡¡gacutil¡¡tool¡¡can¡¡be¡¡executed¡¡multiple¡¡times¡¡with¡¡multiple¡¡versions£»¡¡as¡¡shown¡¡in¡¡Figure¡¡12¡4¡£¡¡
¡öNote¡¡¡¡For¡¡more¡¡information¡¡about¡¡using¡¡versioning¡¡tools£»¡¡see¡¡this¡¡blog¡¡entry¡¡about¡¡auto¡incrementing¡¡¡¡
assembly¡¡versions£º¡¡http£º//weblogs¡£asp/bradleyb/archive/2005/12/02/432150¡£aspx¡£¡¡
Figure¡¡12¡4¡£¡¡An¡¡assembly¡¡added¡¡three¡¡times¡¡to¡¡the¡¡GAC¡¡with¡¡three¡¡different¡¡versions¡¡
¡¡¡¡¡¡¡¡¡¡In¡¡Figure¡¡12¡4£»¡¡the¡¡assembly¡¡VersioningAssembly¡¡has¡¡been¡¡added¡¡three¡¡times¡¡to¡¡the¡¡GAC¡¡¡¡
with¡¡three¡¡different¡¡versions¡¡£¨1¡£0¡£0¡£0£»¡¡1¡£1¡£0¡£0£»¡¡an¡¡d¡¡1¡£2¡£0¡£0£©¡£¡¡With¡¡the¡¡GAC¡¡in¡¡this¡¡state£»¡¡an¡¡appli
cation¡¡or¡¡another¡¡assembly¡¡has¡¡the¡¡option¡¡to¡¡reference¡¡three¡¡different¡¡versions¡¡of¡¡the¡¡same¡¡¡¡
assembly¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡358¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
336¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡For¡¡an¡¡application¡¡or¡¡assembly¡¡to¡¡use¡¡another¡¡assembly£»¡¡you¡¡create¡¡a¡¡reference¡£¡¡When¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡application¡¡or¡¡assembly¡¡is¡¡piled£»¡¡a¡¡specific¡¡version¡¡number¡¡of¡¡the¡¡assembly¡¡is¡¡referenced¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡For¡¡example£»¡¡if¡¡a¡¡reference¡¡to¡¡the¡¡version¡¡1¡£1¡£0¡£0¡¡of¡¡VersioningAssembly¡¡is¡¡defined£»¡¡then¡¡version¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡1¡£1¡£0¡£0¡¡of¡¡the¡¡assembly¡¡is¡¡loaded¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Adding¡¡an¡¡Assembly¡¡Redirection¡¡to¡¡a¡¡Configuration¡¡File¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Let¡¯s¡¡say¡¡an¡¡application¡¡or¡¡assembly¡¡needs¡¡to¡¡use¡¡a¡¡new¡¡version¡¡of¡¡the¡¡VersioningAssembly¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡assembly¡£¡¡To¡¡make¡¡the¡¡application¡¡or¡¡assembly¡¡aware¡¡of¡¡the¡¡new¡¡assembly£»¡¡you¡¡update¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡application¡¡or¡¡assembly¡¡configuration¡¡file¡¡that¡¡references¡¡the¡¡old¡¡assembly¡£¡¡The¡¡configuration¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡file¡¡update¡¡includes¡¡an¡¡assembly¡¡redirection¡£¡¡Essentially£»¡¡what¡¡the¡¡redirection¡¡says¡¡is¡¡that¡¡if¡¡a¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡certain¡¡version¡¡of¡¡an¡¡assembly¡¡is¡¡requested£»¡¡the¡¡new¡¡version¡¡should¡¡be¡¡loaded¡£¡¡The¡¡following¡¡is¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡an¡¡example¡¡of¡¡an¡¡assembly¡¡redirection¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿!
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾Ñé½±Àø£¬ÈÏÕæдԴ´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾Ñé½±ÀøŶ£¡