Assembly Resolver ignores PrivateBinPath

Go To StackoverFlow.com

3

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?

2012-04-04 23:25
by user472875
Please consider acccepting one of the answer - aKzenT 2012-04-05 19:14
Neither answer solves my problem, I needed to look in the PrivateBinPath first and then in the ApplicationBase, which won't happen with PrivateBinPathProbe - user472875 2012-04-05 19:34
If you read the question in full, the answer does not "force the search even if the wrong version is found". However, because you took the time to teach me manners, I will give you the answer. As for your second point: I agree the question is similar and I admit I am in a very big rush to finish this code, which is the only reason I opened a new question for it. I did link to it in my new post - user472875 2012-04-05 20:21


2

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

2012-04-04 23:28
by aKzenT


1

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.

2012-04-04 23:29
by Jon Skeet
Looks I'll have to adapt the design to search only in the PrivateBinPath in that case. What I don't understand is why the resolver gives up after finding the wrong version, without checking in the private path. Seems crude - user472875 2012-04-05 13:45
I tested changing the PrivateBinPathProbe. I do need the resolver to search in the appbase for this to work, so this isn't an option - user472875 2012-04-05 15:18
Ads