首页 > 其他 > 详细

绑定程序集

时间:2014-12-15 06:42:37      阅读:281      评论:0      收藏:0      [点我收藏+]

需要配置配置文件

 

1,codeBase:只可用于共享程序集

①:从网络加载

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  
  
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
      <dependentAssembly>  
        <assemblyIdentity name="Timber.Assembly" version="1.0.0.0" publicKeyToken="ad83e08169849671"/>
      <codeBase version="1.0.0.0" href="http://192.188.1.106:8089/dll/Timber.Assembly.dll" />
      </dependentAssembly>  
  </assemblyBinding> 
</runtime>
</configuration>

 

②:指定文件的路径

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  
  
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
      <dependentAssembly>  
        <assemblyIdentity name="Timber.Assembly" version="1.0.0.0" publicKeyToken="ad83e08169849671"/>
      <codeBase version="1.0.0.0" href="file://C:\Users\Administrator\Desktop\Timber.Assembly\Timber.Assembly\bin\Debug\Timber.Assembly.dll" />
      </dependentAssembly>  
  </assemblyBinding> 
</runtime>
</configuration>

publicKeyToken:该程序集的公钥

可以通过sn -T Timber.Assembly.dll 查看公钥

 

 

=====================测试:

Assembly a = Assembly.Load("Timber.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ad83e08169849671");
            Console.WriteLine(a.FullName);
            Console.ReadKey();

 

 

2,probing:可用于共享和私有程序集

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <runtime>
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="zhangdi;bin"></probing>
    </assemblyBinding>
  </runtime>
</configuration>

 privatePath:指定检索程序集的路径

 

 =====================测试:

 Assembly a = Assembly.Load("ClassLibrary1, Version=1.0.0.0");
 Console.WriteLine(a.FullName);
 Console.ReadKey();

本文出自 “程序猿的家--Hunter” 博客,请务必保留此出处http://962410314.blog.51cto.com/7563109/1589850

绑定程序集

原文:http://962410314.blog.51cto.com/7563109/1589850

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!