首页 > 代码库 > 绑定程序集
绑定程序集
需要配置配置文件
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
绑定程序集
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。