我有一个程序集 A 定义了一个带有一些重载的接口:
public interface ITransform
{
Point InverseTransform(Point point);
Rect InverseTransform(Rect value);
System.Drawing.Point InverseTransform(System.Drawing.Point point);
}
...以及引用 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);
}
准确地说,它调用了方法的System.Windows.Point
重载InverseTransform
,因为那是 中属性的Location
类型e
。
但是当我在 IDE 中构建 B 时,我得到:
错误 CS0012:“System.Drawing.Point”类型在未引用的程序集中定义。您必须添加对程序集“System.Drawing,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”的引用。
即使这甚至不是我打电话的超载。当我注释掉InverseTransform
调用重载方法的行时,即使我仍在实例化类型的对象,它也可以正常构建ITransform
。
为什么?有没有办法解决这个问题而不必在System.Drawing
任何地方添加引用?