Ryan
Ryan

Reputation: 24482

BindingRedirect to different assembly name

You can use BindingRedirect to redirect YourAssembly.dll 1.1.0.0 to 1.2.0.0.

Does anyone know if its possible to do this if the assembly names are different.

E.g.

YourAssembly1.dll (v1.1) redirects to YourAssembly2.dll (v2.8)

Upvotes: 25

Views: 4956

Answers (3)

Szymon Rozga
Szymon Rozga

Reputation: 18178

If I recall correctly, I did this about 4 years ago using the AppDomain.AssemblyResolve event. The idea is that you get the AssemblyName request and you return an Assembly. In some cases, I was even able to generate DynamicAssembly at runtime and inject that. I forget what effects strong naming has on this.

Upvotes: 11

Jehof
Jehof

Reputation: 35554

This should not be possible, due to the fact that your own application has a reference to YourAssembly1.

When the runtime loads your application it tries to load an assembly YourAssembly1.dll (applying probing and version redirects) and therefore it cannot load the assembly YourAssembly2 instead.

Upvotes: 0

Alex Dresko
Alex Dresko

Reputation: 5213

Use ILDASM and ILASM to decompile, modify, and recompile the original assembly so it references YourAssembly2.dll.

I got the idea in my head and did a couple of searches to verify it's possible. See Is it possible to modify assembly manifests other than by ILDASM/ILASM hacking? and http://forums.asp.net/t/1582934.aspx/1

Upvotes: 0

Related Questions