我有两个项目。
第一个是带有下一个界面的Wpf Project(FrameWork 3.5):
public interface View
{
ObservableCollection<int> Items { set; }
}
public class ViewFake:View
{
public ObservableCollection<int> Items
{
set { throw new NotImplementedException(); }
}
}
ViewFake' does not implement interface member 'View.Items'. 'ViewFake.Items' cannot implement 'View.Items' because it does not have the matching return type of 'System.Collections.ObjectModel.ObservableCollection`1'.
最佳答案
如果我没记错的话,ObservableCollection是位于.NET 3.5的System.Windows。*命名空间中,只有在4.0中,它才移至System.Collections.ObjectModel命名空间。
* update:更改的不是 namespace ,而是程序集。但是结果是相同的:.NET认为它是不同的类型,因为包含的程序集是类型信息的一部分。
这里更大的问题是您的测试和被测试的类正在使用不同的.NET Framework版本和不同版本的Common Language Runtime。那可能会流下眼泪。您的项目可以使用相同的版本吗?
https://stackoverflow.com/questions/12011044/