Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BindingRedirect to different assembly name

Tags:

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)

like image 548
Ryan Avatar asked Aug 19 '09 18:08

Ryan


People also ask

What is Assembly redirect?

This means that if two components reference different versions of the same strong-named assembly, the runtime automatically adds a binding redirection to the newer version of the assembly in the output app configuration (app. config) file.

How do I stop redirect binding?

Disable through project propertiesRight-click the project in Solution Explorer and select Properties. On the Application page, uncheck the Auto-generate binding redirects option. If you don't see the option, you'll need to manually disable the feature in the project file.

What is Post policy reference?

My understanding is that "Post-policy reference" is the assembly reference after publisher policies, and in general assembly redirections, have occured.

How do I add-BindingRedirect?

Open the NuGet Package Manager Console, specify the appropriate Default Project and enter the command Add-BindingRedirect. As if by magic, an app. config is added to the project (if one doesn't exist already) and the appropriate information added. Sweet!


1 Answers

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.

like image 187
Szymon Rozga Avatar answered Oct 10 '22 03:10

Szymon Rozga