Usage of Observable Collection

Jun 8, 2009 at 12:50 PM

Hi,

I have found that GMap uses an own definition of

   public class ObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged

Is there a specific reason for this? Why not using the class in the WindowsBase Assembly of .NET 3.0?

Using your map control now interferes with other code of my applications.

br, Marcel

Jun 8, 2009 at 12:53 PM

and how he can interfere ? ;D

Jun 8, 2009 at 1:01 PM

Hi radioman,

when we use the WindowsBase Assembly, there will be 2 definitions of the ObservableCollection, one from your project, and the one by Microsoft. See below, when I compile.

Error 2 The type 'System.Collections.ObjectModel.ObservableCollection<T>' exists in both 'd:\SRVDIS\HR310001_PerMIT_Prepare\trunk\SOURCE\Modules\RouteMan\Ihc.Geo.RouteMapControl\GMap.NET.WindowsForms.dll' and 'c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll'

The first DLL is where the GMap control resides, and the other one is a proprietary DLL where we use Observable collections, via referencing of WindowsBase DLL.

My question is, why not using the Microsoft/.NET one in the GMap project in the first place. The only thing you need to do is add a reference to WindowsBase, and voila, you use the code from Microsoft. There is no need to have that class coded for your own, IMHO.

Hope this makes sense.

Br, Marcel

Jun 8, 2009 at 1:04 PM

that collection is only for .net2, why you use winforms in wpf?

Jun 8, 2009 at 1:29 PM

Hi radioman,

Yes, I use winforms, but my project will be entierly in winforms. I do not use WPF at all. I have seen, that in the WPF part of your code, you already use WindowsBase. WindowsBase is not available in the .NET Framework version 2. However, the relevant projects in your solution are of Version 2.0. Is this because of some compatibility reason?

Here’s what I did:

Changed the Framwork version of the GMap.Net.WindowsForms project to 3.5, added the WindowsBase DLL as Reference.

The same for the WinForms Demo Project.

Removed the OvservableCollection and ObservableCollectionThreadsafe classes.

Compiling, ready!

Now I do not have the error anymore.

Br, Marcel

Jun 8, 2009 at 5:11 PM
Edited Jun 8, 2009 at 5:19 PM

yes, but thats exactly why i created these files, to  be not dependend > 2.0, so it works on mono

Jun 9, 2009 at 7:21 AM
Jun 9, 2009 at 11:09 AM

it worker fine before i switched to sqlite cache, i don't test after that, but should be ok