简体   繁体   English

.Net两种不同组件中的相同类型

[英].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.

相关问题 如何从2个不同的程序集加载相同的插件,并在两者之间序列化和反序列化类型? C#.net - How to load same plugins from 2 different assemblies, and serializing and deserializing types between the two? C# .net 在2个.NET程序集中使用相同名称和命名空间的类型 - Use types of same name & namespace in 2 .NET assemblies 可以在一个项目中引用两个具有相同名称的不同程序集吗? 不同的二进制文件 - Possible to reference two different assemblies with the same name in a project? different binaries .NET 中程序集的标记类型是什么? - What are the marker types for assemblies in .NET? 参考程序集文件夹和具有相同版本的不同程序集 - Reference Assemblies folder and different assemblies with the same version 如何从两个不同的子文件夹将两个版本的相同程序集加载到两个不同的域中? - How can I load two versions of same assemblies into two different domains from two different subfolders? 如何在同一解决方案中使用2个不同的log4net程序集 - 每个程序集针对不同版本的.Net Framework? - How to use 2 different log4net assemblies - each targeted for different versions of the .Net Framework, in the same solution? 区分两个相同的私有程序集 - Distinguish two same private assemblies 在不同的程序集中引用相同的接口 - Referencing the same interface in different assemblies 如何在两种相同名称和内部结构之间进行转换,但是来自不同的程序集? - How to cast between 2 types of the same name and internal sturcture but from different assemblies?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM