1.if(是共享程序集)
then 在GAC中搜索相应版本;
私有程序集必须为于应用程序所在目录或子目录中,而共享程序集安装在被称为全局程序集缓存Global Assembly Cache,GAC)的一个特定的全局缓存中。在Windows操作系统中,GAC位于Windows系统目录下的Assembly目录中(例如:C:/WinNT/Assembly),另外注意,只有具备计算机管理员权限才能在GAC中安装程序集。
补充:共享程序集友好名称与私有程序集一样,但是.NET运行库通过强名(strong name)(也称共享名:shared name)来标识共享程序集。一个强名称由友好名称(如MathLibrary)、区域信息(如:英语)、版本号(如1.2.0.0)、公钥(public key)和数字签名等组成。
2.if(未找到)
then 到应用程序的基目录中;
3.if((未找到) && (应用程序的基目录中有.config文件))
then 到配置文件指定的位置搜索;
e.g.(From《Microsoft.Net框架程序设计》):
<?xml version="1.0" encoding="utf=8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- 该元素的内容指示CLR在应用程序基目录下的AuxFiles和bin/subdir子目录中查找弱命名程序集。
对于强命名程序集,CLR会在GAC中或者codeBase元素指定的RUL中查找。
仅当没有指定codeBase元素时,CLR才会在应用程序的私有路径下查找强命名程序集。-->
<probing privatePath="AuxFiles;bin/subdir"/> <!--指定目录,用分号隔开-->
<dependentAssembly>
<assemblyIdentity name="JeffTypes" publicKeyToken="……" culture="neutral"/>
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
<codeBase version="2.0.0.0" href="http://www.Wintellect.com/JeffTypes.dll"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="FredTypes" publicKeyToken="……" culture="neutral"/>
<bindingRedirect oldVersion="3.0.0.0-3.5.0.0" newVersion="4.0.0.0"/>
<publisherPolicy apply="no"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
4.if(未找到)
then 引发异常,程序终止。