简体   繁体   中英

.Net same types in two different assemblies

I have an application that loads two assembly dlls. First dll is a common dll and the second dll has reference to another version of the first dll. All assemblies are unsigned.

App.exe --> dll1_v1.dll, dll2.dll
dll2.dll --> dll1_v2.dll

Both dll1_v1.dll and dll1_v2.dll have same types but different implementations.

If I have both dll1_v1.dll and dll1_v2.dll in the codebase path of the exe, then both get loaded and all object instances in app.exe point to dll1_v1.dll and in dll2 point to dll1_v2.dll.

If I need to point dll1_v2 to dll1_v1, is it correct to remove dll1_v2.dll from the codebase and add AssemblyResolve event handler so I can return the Assembly for dll1_v1.dll in place of dll1_v1.dll?

You can reference different version of same class by extern alias keyword. Following blog post explain it nicely.

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