简体   繁体   English

我可以拆分.net DLL而不必重新编译引用原始DLL的其他DLL吗?

[英]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以表示该类型已被移动。

See this link for detailed information. 有关详细信息,请参阅此链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在c#asp.net中为一个引用其他dll的类创建dll? - How to create a dll for one class that reference other dlls in c# asp.net? 一个带有两个dll的Web应用程序。 一个dll依赖于另一个。 为什么必须同时更新两个DLL? - One web application with two dlls. One dll is dependent upon the other. Why do I have to update both DLLs? 我可以引用 .NET 可执行文件,就好像它是 LINQPad 6 中的 DLL 一样? - Can I reference a .NET executable as if it is a DLL in LINQPad 6? 如何在不访问原始项目的情况下删除项目? - How can I delete a project without having access to the original project? 我可以从 .NET 6 项目中添加对 .NET 框架 DLL 的引用吗? - Can I add a reference to a .NET Framework DLL from a .NET 6 project? 如何在不重新编译的情况下动态切换 .NET 中的 Web 服务地址? - How can I dynamically switch web service addresses in .NET without a recompile? 如何更改某些包含引用类型对象的复制列表而不更改原始列表 - How can I make changes to some Copied list that contains reference-type objects without changing the original one 如何在 C# 中毫无问题地添加 dll 参考? - How can I add a dll reference in C# without problems? 我如何在没有任何公共成员的情况下引用dll? - How can I reference a dll without any public members? 在没有单独的dll的情况下引用其他项目 - Reference other project in solution without separate dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM