微软是如何创建具有循环引用的程序集? [英] How did Microsoft create assemblies that have circular references?

查看:126
本文介绍了微软是如何创建具有循环引用的程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET BCL有之间循环引用:

In the .NET BCL there are circular references between:

  • System.dll中 system.xml.dll的
  • System.dll中 System.Configuration.dll
  • system.xml.dll的 System.Configuration.dll
  • System.dll and System.Xml.dll
  • System.dll and System.Configuration.dll
  • System.Xml.dll and System.Configuration.dll

下面是从.net反射的屏幕截图,显示了我的意思:

Here's a screenshot from .NET Reflector that shows what I mean:

微软如何创造了这些组件是一个谜给我。是否需要特殊的编译过程允许这样做?我想一些有趣的事情是怎么回事。

How Microsoft created these assemblies is a mystery to me. Is a special compilation process required to allow this? I imagine something interesting is going on here.

推荐答案

我只能告诉Mono项目是如何做到这一点。该定理是很简单,但它提供了code一塌糊涂。

I can only tell how the Mono Project does this. The theorem is quite simple, though it gives a code mess.

他们首先编译System.Configuration.dll,而不需要部分的参考system.xml.dll的。在此之后,他们编system.xml.dll的正常方式。现在到了魔术。他们重新编译System.configuration.dll,与部分需要提及system.xml.dll的。现在有一个成功的编译与循环引用。

They first compile System.Configuration.dll, without the part needing the reference to System.Xml.dll. After this, they compile System.Xml.dll the normal way. Now comes the magic. They recompile System.configuration.dll, with the part needing the reference to System.Xml.dll. Now there's a successful compilation with the circular reference.

在短期:

  • 系统编译没有code 需要B和引用到B。
  • B的编译。
  • 在A被重新编译。
  • A is compiled without the code needing B and the reference to B.
  • B is compiled.
  • A is recompiled.

这篇关于微软是如何创建具有循环引用的程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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