简体   繁体   中英

WPF, multiple versions of third-party control

I have a WPF application, which utilizes various third-party controls in numerous projects. In one of these projects, I need to upgrade a particular control to the latest version, while leaving the other projects grid control intact with the earlier version. Can anyone recommend articles, sample code, etc., which shows how to do this? Simply put, I need to do something like this:

  • MainAppModule.csproj, references and deploys all shared dll's to ...\\lib folder
    • ModuleA.csproj, references ThirdParty.dll, v1.0
    • ModuleB.csproj, references ThirdParty.dll, v2.0

Is assembly binding redirect what is needed here? If so how would it be set up?

I dont know what you mean by assembly-binding-redirect...

And i am not really sure if this works for you since both assemblies will have the same namespace...

But you can try it with a custom AppDomain.CurrentDomain.AssemblyResolve . This event handler is called when a class or struct is about to be created or used and the assembly of this type is currently not availiable. So, first you have to move those assemblies out of the default resolution path of your project so this event handler will be called. When its called you know that one of those two versions is needed and by looking at ResolveEventArgs.Name you'll know which version is required. Then you load this assembly and return it from the event handler.

Be sure to check that the event handler is called exactly twice so that both versions are loaded...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM