Can I modify the side-by-side assembly search sequence?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 09:54:09

My first response is, what actual benefit is derived from separating the utilities from the .\bin folder? Having OCD tendencies myself, I understand the sense of neatness but it seems a bit pointless to continue a practice once it so tangibly can be seen to negatively effect your ability to deploy your application.

That said, it is actually technically possible. To do this you make use of the probing privatePath element in your app.config file. Application config files work similarly to application manifests, except that they cannot be embedded as resources: Create a file, in the same folder as the exe, with the exe's full name (including exe extension) and append .config.

<!-- acme.exe.config -->
<configuration>   
  <windows>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin;..\bin" />
    </assemblyBinding>
  </windows>
</configuration>

There are a number of caveats that make this solution potentially unworkable - any dll's that specify their own dependent assemblies need to have an application config file with a probing privatePath element. Also support for the probing node was only added in Windows NT 6.0 (Vista) so this solution is inappropriate if you still need to target XP.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!