[英]Can I split a .net DLL without having to recompile other DLLs that reference the original one?
I have a C# project that builds into a single DLL with two classes, ClassA and ClassB. 我有一个C#项目,它构建成一个DLL,有两个类,ClassA和ClassB。 For project management reasons, I'd like to move ClassB into a separate DLL, leaving the original DLL with ClassA only.
出于项目管理的原因,我想将ClassB移动到一个单独的DLL中,只保留原始DLL与ClassA。
The problem is that I have other DLLs (also compiled from C#) that reference ClassA and ClassB in their original DLL. 问题是我有其他DLL(也是从C#编译)在其原始DLL中引用ClassA和ClassB。 ClassA is fine but calling ClassB ends up with a TypeLoadException.
ClassA很好但是调用ClassB最终会产生TypeLoadException。
(I could recompile all of those other DLLs with their new project references, but I'd rather not do that, again for project management reasons.) (我可以使用他们的新项目引用重新编译所有其他DLL,但出于项目管理的原因,我宁愿不这样做。)
Is there a way I could deploy my new split DLLs and have the other DLLs continue to work? 有没有办法我可以部署我的新拆分DLL并让其他DLL继续工作? Or, do I really need to bite the proverbial bullet and plan to deploy new versions of all these files?
或者,我是否真的需要咬住众所周知的子弹并计划部署所有这些文件的新版本?
You achieve this using Type forwarding . 您可以使用Type forwarding实现此目的。 This enables moving a type to another assembly.
这样可以将类型移动到另一个组件。 In the original assembly, you add a
TypeForwardedTo
-attribute to signal that the type has been moved. 在原始程序
TypeForwardedTo
,添加一个TypeForwardedTo
-attribute以表示该类型已被移动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.