Can I split a .net DLL without having to recompile other DLLs that reference the original one?

China☆狼群 提交于 2019-12-12 09:55:43

问题


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.

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.

(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.)

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?


回答1:


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.



来源:https://stackoverflow.com/questions/47635419/can-i-split-a-net-dll-without-having-to-recompile-other-dlls-that-reference-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!