Is it possible to programmatically redirect assembly

We are using the Microsoft Unity framework for dependency injection in some new class libraries. The main application is the use of some other corporate libraries (Common and Logging) that expect Unity v2.0.414, but we implemented our libraries with Unity v2.1.515.

To get around the version differences, I created the app.Config application for the main application and put the bindingRedirect entry in the configuration file, and it works fine. However, we just found out that the application has never used app.config at this point, and mgmt prefers it that way.

. Is it possible to programmatically implement assembly redirection (i.e. in code)? Thanks!

+4
source share
1 answer

Have you tried the AppDomain.AssemblyResolve event?

This post can also help you. How to use assembly binding redirection to ignore version and assembly numbers

public void Load(string assembly) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Method); Assembly assembly = Assembly.LoadFrom(assemblyFile); // ... } 
+6
source

Source: https://habr.com/ru/post/1484511/


All Articles