How to derive from an internal interface in another assembly
<p>I'm a C# newbie, so please bear with me. </p>

<p>OK, so I have two classes in different assemblies that need to reference each other:</p>

<pre><code>namespace AssemblyA
{
  class A 
  {
    private B MyB { get; set; }
  }
}

namespace AssemblyB
{
  class B
  {
    private A MyA { get; set; }
  }
}
</code></pre>

<p>I understand that circular references aren't allowed, so I'm using an interface:</p>

<pre><code>namespace AssemblyA
{
  public interface IB
  {
     // whatever 'A' needs of 'B'
  }

  class A 
  {
    private IB MyB { get; set; }
  }
}

namespace AssemblyB
{
  class B : AssemblyA.IB
  {
    private A MyA { get; set; }
  }
}
</code></pre>

<p>This works, but it has the disadvantage that it exposes <code>IB</code> to the rest of the world. What I would like to do instead is to make <code>IB</code> <code>internal</code>. But then <code>B</code> cannot derive from it. </p>

<p>In C++, I'd make <code>B</code> a friend and be done. I understand that C# doesn't have friends (pun not intended, but noted), so I have to make do without. <em>I've read that there is an attribute for that, but this will make the whole of assembly <code>A</code> accessible to the whole of assembly <code>B</code>, which I don't like.</em> Is there a way to avoid that? </p>
