是否可以拆分.net DLL而不用重新编译引用原始DLL的其他DLL? [英] Can I split a .net DLL without having to recompile other DLLs that reference the original one?

查看:140
本文介绍了是否可以拆分.net DLL而不用重新编译引用原始DLL的其他DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#项目,该项目内置到具有两个类ClassA和ClassB的单个DLL中.出于项目管理的原因,我想将ClassB移到一个单独的DLL中,而将原来的DLL仅留给ClassA.

I have a C# project that builds into a single DLL with two classes, ClassA and ClassB. For project management reasons, I'd like to move ClassB into a separate DLL, leaving the original DLL with ClassA only.

问题是我还有其他DLL(也从C#编译),它们在其原始DLL中引用了ClassA和ClassB. ClassA很好,但是调用ClassB最终会引发TypeLoadException.

The problem is that I have other DLLs (also compiled from C#) that reference ClassA and ClassB in their original DLL. ClassA is fine but calling ClassB ends up with a TypeLoadException.

(我可以用其他新的DLL重新编译它们的新项目引用,但是出于项目管理的原因,我宁愿不这样做.)

(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,并使其他DLL继续工作?或者,我真的需要咬紧牙关,计划部署所有这些文件的新版本吗?

Is there a way I could deploy my new split DLLs and have the other DLLs continue to work? Or, do I really need to bite the proverbial bullet and plan to deploy new versions of all these files?

推荐答案

您可以使用类型转发来实现.这样可以将类型移动到另一个部件.在原始程序集中,您添加一个TypeForwardedTo属性以指示该类型已被移动.

You achieve this using 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.

请参见

See this link for detailed information.

这篇关于是否可以拆分.net DLL而不用重新编译引用原始DLL的其他DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆