How to create circularly referenced assemblies

In .Net framework System.dll and System.Xml.dll reference each other. How is it possible?

Circularly referenced assemblies are chicken-and-egg problem. The trick is how to break the dependency chain.

Here is one way I find working.

Step 1. Create assembly A, includes A only types. A references nothing. (Except framework assemblies).
Step 2. Create assembly B, uses A's types, and includes B only interfaces. B now references A.
Step 3. Re-write A, includes A only types, and uses types in B. Now A also references B.

Now you have A and B reference each other.

Let's put it in code.

Step 1: a.cs
using System;

public interface IA
{
    String IAMethod();
}

c:\>csc /t:library a.cs

Step 2: b.cs
using System;

public interface IB
{
    String IBMethod();
}

class InheritA: IA
{
    public String IAMethod()
    {
        return Type.GetType("InheritA").ToString();
    }
}

c:\>csc /t:library /r:a.dll b.cs

Step3: a.cs
using System;

public interface IA
{
    String IAMethod();
}

public class InheritB: IB
{
    public String IBMethod()
    {
        return Type.GetType("InheritB").ToString();
    }
}

c:\>csc /t:library /r:b.dll a.cs

Done!