Search code examples
c#.netinotifycollectionchanged

Where is INotifyCollectionChanged?


I'm trying to use MS' ObservableConcurrentDictionary sample, but I ran into a completely unexpected problem.

INotifyCollectionChanged interface is NOT found in System.Collections.Specialized namespace. The project is WinForms, and I tried targeting .NET 3.5 and 3.5 Client Profile to no avail, despite MSDN saying it's supported. There is nothing found in the assemblies that has Colections in it, so I suppose I'm not missing any references either. Google search was inconclusive, apparently I'm the only one in the whole wide world to have such a problem.

Just what the hell is wrong with this thing?

Here is a screenshot. Note how System.Collections.Specialized is marked as unused.

Screenshot of VS interface. Note how System.Collections.Specialized is marked as unused.


Solution

  • In .NET 3.5, INotifyCollectionChanged was compiled as part of WindowsBase.dll. Only in .NET 4.0 was it moved to the core System.dll. You'll have to add a reference to WindowsBase to access it.

    However, I'm not aware of the INotifyPropertyChanged/INotifyCollectionChanged being relevant for WinForms - they're a core part of the WPF MVVM Binding experience. Are you sure they're the tool you want to use?