有的时候由于某种需求,需要我们的Dll在主程序的不同的子目录中,为了能够让程序启动时能够正确加载Dll需要配置一下Runtime配置节。该方法在.net1.1,2.0的Winform程序测试通过。
在你的应用程序项目中加入config文件,如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Lib"/>
<dependentAssembly>
<assemblyIdentity name="ClassLibrary1" publicKeyToken="null" culture="neutral" />
<codeBase version="0.0.0.0" href="Lib/ClassLibrary1.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>