[英].Net same types in two different assemblies
I have an application that loads two assembly dlls. 我有一个加载两个组装dll的应用程序。 First dll is a common dll and the second dll has reference to another version of the first dll. 第一个dll是一个常见的dll,第二个dll引用了第一个dll的另一个版本。 All assemblies are unsigned. 所有程序集都是未签名的。
App.exe --> dll1_v1.dll, dll2.dll App.exe - > dll1_v1.dll,dll2.dll
dll2.dll --> dll1_v2.dll dll2.dll - > dll1_v2.dll
Both dll1_v1.dll and dll1_v2.dll have same types but different implementations. dll1_v1.dll和dll1_v2.dll都具有相同的类型但实现方式不同。
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. 如果我在exe的代码库路径中同时包含dll1_v1.dll和dll1_v2.dll,则两者都会被加载,app.exe中的所有对象实例都指向dll1_v1.dll,而dll2指向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? 如果我需要将dll1_v2指向dll1_v1,从代码库中删除dll1_v2.dll并添加AssemblyResolve事件处理程序是否正确,以便我可以返回dll1_v1.dll的程序集来代替dll1_v1.dll?
You can reference different version of same class by extern alias keyword. 您可以通过extern alias关键字引用同一类的不同版本。 Following blog post explain it nicely. 以下博客文章很好地解释了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.