Doing DotSpatial Programming in Visual C# 2010 Express: To create a new point by clicking the 'btnCoord" button that was on Form1 - 4 errors

Feb 10, 2011 at 2:04 PM
Edited Feb 10, 2011 at 5:56 PM

Hi all,

In my Microsoft Visual C# 2010 Express that has "DotSpatial" (built from DotSpatial 12-15-2010 dll library) in the Toolbox (in the left-side panel), I lanched a new project "scDotSpatial_NewPoint-btnCoord", I did "Add Reference" for DotSpatial.Data.dll and  DotSpatial.Topology.dll (from DotSpaital 12-15-2010) in the "References" under the Solution of my project (in the right-side panel), I changed the Target Framework to .NET Framework 4,  I dragged a regular button from the Toolbox and changed the Text and Name from button1 to btnCoord, and then I added the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DotSpatial.Data;
using DotSpatial.Topology;
// using DotSpatial.Common; 

namespace scDotSpatial_NewPoint_btnCoord
    public partial class Form1 : Form
        public Form1()

        private void btnCoord_Click(object sender, EventArgs e)
            //creates a new coordinate 
            Coordinate c = new Coordinate(2.4, 2.4);
            //passes the coordinate to a new point
            Point p = new Point(c);
            //displayes the new point's x and y coordiantes
            MessageBox.Show("Point p is: x= " + p.X + " & y= " + p.Y);   

I executed my project and I got the following 4 errors:
Error 1 'Point' is an ambiguous reference between 'System.Drawing.Point' and 'DotSpatial.Topology.Point' C:\Documents and Settings\e1enxshc\my documents\visual studio 2010\Projects\scDotSpatial_NewPoint-btnCoord\scDotSpatial_NewPoint-btnCoord\Form1.cs 27 13 scDotSpatial_NewPoint-btnCoord
Error 2 The best overloaded method match for 'System.Drawing.Point.Point(System.Drawing.Size)' has some invalid arguments C:\Documents and Settings\e1enxshc\my documents\visual studio 2010\Projects\scDotSpatial_NewPoint-btnCoord\scDotSpatial_NewPoint-btnCoord\Form1.cs 27 23 scDotSpatial_NewPoint-btnCoord
Error 3 'Point' is an ambiguous reference between 'System.Drawing.Point' and 'DotSpatial.Topology.Point' C:\Documents and Settings\e1enxshc\my documents\visual studio 2010\Projects\scDotSpatial_NewPoint-btnCoord\scDotSpatial_NewPoint-btnCoord\Form1.cs 27 27 scDotSpatial_NewPoint-btnCoord
Error 4 Argument 1: cannot convert from 'DotSpatial.Topology.Coordinate' to 'System.Drawing.Size' C:\Documents and Settings\e1enxshc\my documents\visual studio 2010\Projects\scDotSpatial_NewPoint-btnCoord\scDotSpatial_NewPoint-btnCoord\Form1.cs 27 33 scDotSpatial_NewPoint-btnCoord
I do not know why these errors occurred and how to resolve them.  Please kindly help and advise.
Thanks in advance,
Scott Chang
Feb 10, 2011 at 3:45 PM

Hi Scott,

The error message is because there is a class named "Point" both in the System.Drawing and in the DotSpatial.Topology namespace.

instead of

Point p = new Point(c)


DotSpatial.Topology.Point p = new DotSpatial.Topology.Point(c)


Feb 10, 2011 at 5:34 PM

Hi Jiri,  Thanks for your nice response.

It worked nicely.   Wonderful!!!

(1) I want to add a point or few points (say 3 points) to an existing Shapefile (.shp extension).  How can I do this kind of DotSpatial programming in Visual C# 2010 Express?

(2) If I need to attach the Attribute Table to each point of (1), how can I do this new task of attaching the Attribute Table to each point?

 Please enlighten me in doing the above-mentioned 2 tasks.  Please respond and advise.

Thanks again,

Scott Chang