ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡
VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ)-µÚ86²¿·Ö
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿! Èç¹û±¾ÊéûÓÐÔĶÁÍ꣬ÏëÏ´μÌÐø½Ó×ÅÔĶÁ£¬¿ÉʹÓÃÉÏ·½ "Êղص½ÎÒµÄä¯ÀÀÆ÷" ¹¦ÄÜ ºÍ "¼ÓÈëÊéÇ©" ¹¦ÄÜ£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡329¡¡
Imports¡¡System¡£Configuration¡¡
Public¡¡Class¡¡LoaderSection¡¡
¡¡¡¡¡¡¡¡Inherits¡¡ConfigurationSection¡¡
¡¡¡¡¡¡¡¡Private¡¡Shared¡¡_propAssemblyName¡¡As¡¡ConfigurationProperty¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡New¡¡ConfigurationProperty£¨¡¨assemblyname¡¨£»¡¡GetType£¨String£©£»¡¡Nothing£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ConfigurationPropertyOptions¡£IsRequired£©¡¡
¡¡¡¡¡¡¡¡Private¡¡Shared¡¡_propEasyName¡¡As¡¡ConfigurationProperty¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡New¡¡ConfigurationProperty£¨¡¨easyname¡¨£»¡¡GetType£¨String£©£»¡¡Nothing£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ConfigurationPropertyOptions¡£IsRequired£©¡¡
¡¡¡¡¡¡¡¡Private¡¡Shared¡¡_properties¡¡As¡¡ConfigurationPropertyCollection¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡New¡¡ConfigurationPropertyCollection£¨£©¡¡
¡¡¡¡¡¡¡¡Private¡¡Shared¡¡_propTypeName¡¡As¡¡ConfigurationProperty¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡New¡¡ConfigurationProperty£¨¡¨typename¡¨£»¡¡GetType£¨String£©£»¡¡Nothing£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ConfigurationPropertyOptions¡£IsRequired£©¡¡
¡¡¡¡¡¡¡¡Shared¡¡Sub¡¡New£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_properties¡£Add£¨_propAssemblyName£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_properties¡£Add£¨_propEasyName£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_properties¡£Add£¨_propTypeName£©¡¡
¡¡¡¡¡¡¡¡End¡¡Sub¡¡
¡¡¡¡¡¡¡¡¡¡_¡¡
¡¡¡¡¡¡¡¡Public¡¡ReadOnly¡¡Property¡¡AssemblyName£¨£©¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡CStr£¨MyBase¡£Item£¨_propAssemblyName£©£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡End¡¡Property¡¡
¡¡¡¡¡¡¡¡¡¡_¡¡
¡¡¡¡¡¡¡¡Public¡¡ReadOnly¡¡Property¡¡EasyName£¨£©¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡CStr£¨MyBase¡£Item£¨_propEasyName£©£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡End¡¡Property¡¡
¡¡¡¡¡¡¡¡¡¡_¡¡
¡¡¡¡¡¡¡¡Public¡¡ReadOnly¡¡Property¡¡TypeName£¨£©¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡CStr£¨MyBase¡£Item£¨_propTypeName£©£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡End¡¡Property¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡352¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
330¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡¡¡LoaderSection¡¡class¡¡does¡¡two¡¡jobs£º¡¡it¡¡tells¡¡the¡¡underlying¡¡configuration¡¡infrastructure¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡what¡¡¡¡LoaderSection¡¡is¡¡interested¡¡in£»¡¡and¡¡it¡¡provides¡¡an¡¡easy¡to¡use¡¡API¡¡to¡¡the¡¡configuration¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡data¡£¡¡The¡¡first¡¡job¡¡is¡¡nice¡¡to¡¡have¡¡done£»¡¡but¡¡the¡¡second¡¡is¡¡absolutely¡¡essential¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡To¡¡understand¡¡what¡¡happens£»¡¡let¡¯s¡¡see¡¡an¡¡example¡¡of¡¡retrieving¡¡the¡¡values¡¡from¡¡a¡¡configu
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ration¡¡file¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Reading¡¡the¡¡Enhanced¡¡Configuration¡¡File¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡As¡¡you¡¯ve¡¡seen£»¡¡the¡¡¡¡element¡¡declares¡¡a¡¡custom¡¡XML¡¡node¡¡that£»¡¡when¡¡encoun
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡tered£»¡¡instantiates¡¡a¡¡specific¡¡type¡ª¡¡LoaderSection¡¡is¡¡instantiated¡¡in¡¡this¡¡example¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡values¡¡are¡¡retrieved¡¡from¡¡the¡¡custom¡¡configuration¡¡as¡¡follows£º¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡The¡¡configuration¡¡infrastructure¡¡reads¡¡the¡¡various¡¡attributes£»¡¡such¡¡as¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡The¡¡configuration¡¡infrastructure¡¡does¡¡a¡¡cross¡reference¡¡of¡¡which¡¡attributes¡¡exist¡¡and¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if¡¡they¡¡are¡¡required¡£¡¡Think¡¡of¡¡this¡¡step¡¡as¡¡the¡¡bookkeeping¡¡of¡¡the¡¡custom¡¡configuration¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡information¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡The¡¡configuration¡¡infrastructure¡¡waits¡¡for¡¡the¡¡application¡¡code¡¡to¡¡call¡¡the¡¡properties¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡EasyName£»¡¡TypeName£»¡¡or¡¡AssemblyName¡£¡¡In¡¡the¡¡implementation¡¡of¡¡the¡¡individual¡¡properties£»¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡MyBase¡¡indexer¡¡£¨such¡¡as¡¡MyBase¡£Item£¨_propTypeName£©¡¡from¡¡¡¡LoaderSection¡£TypeName£©¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡is¡¡referenced£»¡¡and¡¡the¡¡value¡¡of¡¡the¡¡configuration¡¡item¡¡is¡¡retrieved¡¡using¡¡the¡¡property¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡descriptors¡¡declared¡¡as¡¡shared¡¡members¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡We¡¡can¡¡use¡¡the¡¡following¡¡code¡¡to¡¡read¡¡the¡¡custom¡¡configuration¡¡item¡¡£¨added¡¡to¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Definitions¡¡assembly£©¡£¡¡This¡¡code¡¡is¡¡an¡¡example¡¡of¡¡replacing¡¡the¡¡previously¡¡declared¡¡¡¡Load£¨£©¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡functionality¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Load£¨£©¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡loader¡¡As¡¡LoaderSection¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CType£¨ConfigurationManager¡£GetSection£¨¡¨loader¡¨£©£»¡¡LoaderSection£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡loader¡¡IsNot¡¡Nothing¡¡Then¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡configInfo¡¡As¡¡ConfigurationInfo¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡New¡¡ConfigurationInfo£¨£©¡¡With¡¡£û¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£EasyName¡¡=¡¡loader¡£EasyName£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£TypeName¡¡=¡¡loader¡£TypeName£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£AssemblyName¡¡=¡¡loader¡£AssemblyName£ý¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_availableTypes¡£Add£¨loader¡£EasyName£»¡¡configInfo£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡only¡¡major¡¡difference¡¡between¡¡this¡¡code¡¡and¡¡the¡¡previous¡¡¡¡Load£¨£©¡¡code¡¡is¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ConfigurationManager¡¡reference¡£¡¡In¡¡the¡¡previous¡¡¡¡Load£¨£©¡¡implementation£»¡¡it¡¡was¡¡assumed¡¡that¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡all¡¡configuration¡¡settings¡¡were¡¡stored¡¡in¡¡the¡¡¡¡section¡£¡¡This¡¡time£»¡¡we¡¡retrieve¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡section£»¡¡which¡¡is¡¡defined¡¡to¡¡be¡¡the¡¡type¡¡¡¡LoaderSection¡£¡¡We¡¡still¡¡create¡¡all¡¡available¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡types¡¡using¡¡the¡¡_availableTypes¡¡dictionary¡¡collection£»¡¡but¡¡the¡¡parsing¡¡and¡¡breaking¡¡apart¡¡of¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡various¡¡buffers¡¡are¡¡not¡¡necessary¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡353¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡331¡¡
¡öNote¡¡¡¡Writing¡¡your¡¡own¡¡configuration¡¡section¡¡is¡¡not¡¡that¡¡difficult£»¡¡but¡¡it¡¡is¡¡tedious¡£¡¡It¡¡is¡¡tedious¡¡because¡¡you¡¡¡¡
need¡¡to¡¡explicitly¡¡tell¡¡the¡¡configuration¡¡infrastructure¡¡what¡¡every¡¡item¡¡means¡¡and¡¡how¡¡you¡¡will¡¡use¡¡it¡£¡¡There¡¡is¡¡¡¡
no¡¡simple¡¡way¡¡to¡¡get¡¡around¡¡this£»¡¡because¡¡the¡¡configuration¡¡infrastructure¡¡needs¡¡to¡¡know¡¡which¡¡configuration¡¡¡¡
items¡¡should¡¡be¡¡processed¡¡and¡¡how¡¡they¡¡should¡¡be¡¡processed¡£¡¡Thus£»¡¡to¡¡implement¡¡a¡¡configuration¡¡section¡¡¡¡
with¡¡multiple¡¡items£»¡¡you¡¡will¡¡need¡¡to¡¡use¡¡more¡¡pieces¡¡of¡¡the¡¡predefined¡¡configuration¡¡infrastructure¡¡in¡¡the¡¡¡¡
same¡¡manner¡¡as¡¡illustrated¡¡by¡¡this¡¡simple¡¡example¡£¡¡See¡¡the¡¡¡¡configuration¡¡infrastructure¡¡documentation£»¡¡¡¡
at¡¡http£º//support¡£microsoft¡£/kb/313405/EN¡US/£»¡¡for¡¡more¡¡information¡£¡¡
Loading¡¡a¡¡Strongly¡¡Named¡¡Assembly¡¡
In¡¡the¡¡previous¡¡section£»¡¡the¡¡example¡¡demonstrated¡¡the¡¡dynamic¡¡loading¡¡technique¡¡in¡¡which¡¡¡¡
you¡¡explicitly¡¡define¡¡where¡¡the¡¡assembly¡¡is¡¡and¡¡then¡¡instantiate¡¡a¡¡type¡¡in¡¡that¡¡assembly¡£¡¡Another¡¡¡¡
approach¡¡to¡¡instantiating¡¡an¡¡assembly¡¡involves¡¡using¡¡the¡¡formal¡¡declaration¡¡of¡¡a¡¡type¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡In¡¡£»¡¡there¡¡is¡¡an¡¡easy¡¡way¡¡to¡¡reference¡¡an¡¡assembly¡¡and¡¡a¡¡more¡¡difficult¡¡way¡¡to¡¡reference¡¡an¡¡¡¡
assembly¡£¡¡This¡¡is¡¡analogous¡¡to¡¡the¡¡easy¡¡way¡¡to¡¡identify¡¡a¡¡person¡¡and¡¡the¡¡more¡¡plicated¡¡way¡£¡¡¡¡
The¡¡easy¡¡way¡¡to¡¡identify¡¡me¡¡is¡¡to¡¡use¡¡my¡¡name£»¡¡Christian¡¡Gross£»¡¡and¡¡that¡¡works¡¡to¡¡a¡¡degree¡£¡¡The¡¡¡¡
problem¡¡is¡¡that¡¡I¡¯m¡¡not¡¡the¡¡only¡¡Christian¡¡Gross¡¡on¡¡this¡¡planet¡£¡¡The¡¡precise¡¡way¡¡to¡¡find¡¡me¡¡is¡¡to¡¡¡¡
look¡¡at¡¡my¡¡passport¡£¡¡The¡¡passport¡¡approach¡¡works£»¡¡but¡¡it¡¡has¡¡a¡¡long£»¡¡ugly¡¡number¡¡that¡¡is¡¡hard¡¡¡¡
to¡¡remember¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡The¡¡assembly¡¡name¡¡Implementations2¡£dll¡¡is¡¡a¡¡simple¡¡assembly¡¡identifier¡¡like¡¡Christian¡¡Gross¡£¡¡¡¡
The¡¡following¡¡is¡¡the¡¡precise¡¡¡¡identifier¡¡of¡¡the¡¡assembly¡£¡¡
Implementations2£»¡¡Version=1¡£0¡£0¡£0£»¡¡Culture=neutral£»¡¡PublicKeyToken=6bc4c8c27c08ba48¡¡
¡¡¡¡¡¡¡¡¡¡¡¡The¡¡identifier¡¡is¡¡quite¡¡a¡¡mouthful£»¡¡but¡¡it¡¡says¡¡everything¡¡you¡¡need¡¡to¡¡know¡£¡¡This¡¡specifies¡¡¡¡
the¡¡name¡¡as¡¡Implementations2£»¡¡the¡¡version¡¡number£»¡¡the¡¡culture¡¡£¨bination¡¡of¡¡language¡¡and¡¡¡¡
country£©£»¡¡and¡¡a¡¡fixed¡signed¡¡identifier¡£¡¡When¡¡culture¡¡is¡¡defined¡¡as¡¡neutral£»¡¡it¡¡means¡¡that¡¡only¡¡¡¡
the¡¡language¡¡is¡¡taken¡¡into¡¡account¡¡and¡¡not¡¡the¡¡country¡specific¡¡bit¡£¡¡For¡¡example£»¡¡if¡¡the¡¡culture¡¡¡¡
is¡¡en¡CA£»¡¡with¡¡neutral£»¡¡the¡¡CA¡¡bit¡¡will¡¡be¡¡ignored£»¡¡which¡¡means¡¡a¡¡neutral¡¡form¡¡of¡¡English£»¡¡known¡¡¡¡
in¡¡this¡¡context¡¡as¡¡international¡¡English£»¡¡will¡¡be¡¡used¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡Using¡¡all¡¡of¡¡these¡¡attributes£»¡¡you¡¡can¡¡uniquely¡¡identify¡¡an¡¡assembly¡£¡¡This¡¡lets¡¡you¡¡load¡¡a¡¡¡¡
specific¡¡version¡¡of¡¡the¡¡assembly£»¡¡allowing¡¡multiple¡¡similar¡¡assemblies¡¡to¡¡be¡¡loaded¡¡simulta
neously¡£¡¡This¡¡specific¡¡referencing¡¡lets¡¡you¡¡to¡¡use¡¡ponents¡¡according¡¡to¡¡version¡¡and¡¡language¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡The¡¡extra¡¡information¡¡is¡¡specified¡¡in¡¡the¡¡source¡¡code¡¡file¡¡AssemblyInfo¡£vb¡£¡¡If¡¡you¡¡want¡¡to¡¡edit¡¡¡¡
this¡¡file£»¡¡select¡¡the¡¡project¡¡and¡¡then¡¡choose¡¡Project¡¡¡¡Show¡¡All¡¡Files¡£¡¡You¡¯ll¡¡find¡¡the¡¡AssemblyInfo¡£vb¡¡¡¡
file¡¡under¡¡the¡¡My¡¡Project¡¡node¡¡in¡¡the¡¡Solution¡¡Explorer¡£¡¡Following¡¡is¡¡the¡¡plete¡¡implementation¡¡¡¡
for¡¡Implementations2¡£dll¡£¡¡
Imports¡¡System¡¡
Imports¡¡System¡£Reflection¡¡
Imports¡¡System¡£Runtime¡£InteropServices¡¡
¡¡'¡¡General¡¡Information¡¡about¡¡an¡¡assembly¡¡is¡¡controlled¡¡through¡¡the¡¡following¡¡¡¡
¡¡'¡¡set¡¡of¡¡attributes¡£¡¡Change¡¡these¡¡attribute¡¡values¡¡to¡¡modify¡¡the¡¡information¡¡
¡¡'¡¡associated¡¡with¡¡an¡¡assembly¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡354¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
332¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡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¡¡¡¡
¡¡¡¡¡¡¡¡¡¡
¿ì½Ý²Ù×÷: °´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ °´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ °´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿!
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾Ñé½±Àø£¬ÈÏÕæдԴ´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾Ñé½±ÀøŶ£¡