为什么我(有时)必须引用我引用的程序集引用的程序集?

mti*_*ijn 11 c# dependencies visual-studio-2010 .net-assembly c#-4.0

我有一个程序集A,它定义了一些带有一些重载的接口:

public interface ITransform
{
    Point InverseTransform(Point point);
    Rect InverseTransform(Rect value);
    System.Drawing.Point InverseTransform(System.Drawing.Point point);
}
Run Code Online (Sandbox Code Playgroud)

...和一个引用A(二进制文件而不是项目)的程序集B并调用其中一个重载:

var transform =
    (other.Source.TransformToDisplay != null &&
    other.Source.TransformToDisplay.Valid) ?
    other.Source.TransformToDisplay : null;
if (transform != null)
{
    e.Location = transform.InverseTransform(e.Location);
}
Run Code Online (Sandbox Code Playgroud)

准确地说,它调用System.Windows.Point的过载InverseTransform的方法,因为这是属性的类型Locatione.

但是当我在IDE中构建B时,我得到:

错误CS0012:类型'System.Drawing.Point'在未引用的程序集中定义.您必须添加对程序集'System.Drawing,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用.

即使这甚至不是我所说的过载.当我注释掉InverseTransform调用重载方法的行时,即使我仍在实例化类型的对象,它也能正常构建ITransform.

为什么?有没有办法解决这个问题,而无需添加对System.Drawing所有地方的引用?

SLa*_*aks 12

编译器需要知道什么System.Drawing.Point是为了证明它不是正确的重载(例如,如果它具有隐式转换).