Assembly Resolver ignores PrivateBinPath

一笑奈何 提交于 2019-12-23 17:48:13

问题


I have an assembly I would like to load from a sub-folder of the appbase. I set that sub-folder in the PrivateBinPath during AppDomain creation.

The issue is that I have another version of the same DLL in the appbase. From the way it looks, the resolver detects the wrong version first, says that there is a mismatch and stops. As a result the correct version (located in the sub-folder) never gets loaded.

I have tested this by removing those DLLs in the appbase and it fixed the problem. Is there any way to force the search even if the wrong version is found?


回答1:


You can use AppDomainSetup.PrivateBinPathProbe:

AppDomainSetup.PrivateBinPathProbe = "x"

Edit: Just setting this to another value than null is enough, see also this MSDN entry:

http://msdn.microsoft.com/en-us/library/system.appdomainsetup.privatebinpathprobe.aspx




回答2:


Do you only want to use the PrivateBinPath? If so, it looks like you can set PrivateBinPathProbe to any non-null string reference:

Set this property to any non-null string value, including String.Empty (""), to exclude the application directory path — that is, ApplicationBase — from the search path for the application, and to search for assemblies only in PrivateBinPath.

Of course, that doesn't help if you do want to include ApplicationBase, but use the PrivateBinPath in preference.



来源:https://stackoverflow.com/questions/10020645/assembly-resolver-ignores-privatebinpath

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