user472875
user472875

Reputation: 3175

Change Assembly Resolver search order

This is linked to a question I asked yesterday. Briefly, the problem I'm having is that I have two conflicting versions of an assembly. One is in the appbase and the other is in the PrivateBinPath.

From what I understand the assembly resolver searches the appbase first and then searches in the private path. The problem is that, based on what I got by running fusion log, if the resolver finds the wrong version in the appbase it throws an error saying the version doesn't match and stops probing.

I need to use references located in the appbase, so setting the PrivateBinPathProbe is not an option because it excludes the appbase. Is there any way to change the order to search in the PrivateBinPath first?

As a side note, I do not understand why the resolver just gives up if it finds the wrong version.

Upvotes: 3

Views: 1794

Answers (2)

aKzenT
aKzenT

Reputation: 7895

The AssemblyResolve event is only called when the previous lookup was not successfull. So you have to combine the approach from Yahia with the answer from your previous question:

  1. Set PrivateBinPathProbe so that Fusion will not look in the AppBase directory.
  2. Implement an AssemblyResolve event that resolves the path to your AppBase directory.
  3. ...
  4. profit!

The first step is important so that the event gets fired.

Upvotes: 2

Yahia
Yahia

Reputation: 70369

There is AFAIK no option to do that...

You could however implement a workaround:

  • setup an AssemblyResolve handler
  • implement the handler to search wherever you want in whatever preferred order need be

Another option is to embed the dependencies into the EXE/DLL so there is no need to search any path at all - for options to achieve this see here.

Upvotes: 1

Related Questions