I have two projects.
First one is Wpf Project (FrameWork 3.5) with next interface:
public interface View
{
ObservableCollection<int> Items { set; }
}
and the test project (FrameWork 4.0)
public class ViewFake:View
{
public ObservableCollection<int> Items
{
set { throw new NotImplementedException(); }
}
}
I get this error:
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’.
I’ve looked where ObservableCollection is located in both versions, and
So, the only solution is to upgrade the main project or to downgrade the test project?
If I’m not mistaken, ObservableCollection was in the System.Windows.* namespace in .NET 3.5, and only in 4.0 was it moved to the System.Collections.ObjectModel namespace.*update: it wasn’t the namespace that changed, but the assembly. Result is the same, however: .NET considers it a different type because the containing assembly is part of the type information.
The bigger problem here is that your tests and your classes under test are using different .NET framework versions and different versions of the Common Language Runtime. That will likely end in tears. Can you use the same version for your projects?