Doing DotSpatial in Visual C# 2010 Express from ground up: Creating the basic DotSpatial Tools from the DotSpatial Toolbox for spatialToolStrip, Legend-Map Layers, Map, etc.

Jul 30, 2012 at 2:21 PM
Edited Jul 30, 2012 at 2:30 PM

Hi all,

In my Visual C# 2010 Express, I launched a brand new Windows Forms application "scDS1-2expressWinForm1", downloaded DotSpatialPluginTemplateForVSexpressedtions as my DotSpatial class library and added all the dll files as the DotSpatial reference in my application:

(1) From the Toolbox of the DotSpatial, I dragged and dropped the "SpatialToolStrip" to the Form1 of my application "scDS1-2expressWinForm1. I got the most items of the "SpatialToolStrip", except "Zoomin" and "Zoomout"!!??

(2) I can drag the "Legend" and "Map"  from the Toolbox of DotSpatial to the Form1 of my application "scDS1-2expressWinForm1. How can I add "Map Layers" the existing "Legend"? There are LayoutInsert, LayoutDocToolStrip, Modeler, LayoutMapToolStrip, AppManager, LayoutListBox, LayoutControl, SpatialTabControl, LayoutZoomToolStrip, LayoutMenuStrip, LayoutPropertyGrid, ToolManager and Ribben in the Toolbox of DotSpatial. How can I create the Map Layers" in the "Legend" I just dragged and dropped on the Form1 of my application? The "Map" I just dragged and dropped on my Form1 is map1!! Is it right to have map1?  How can I create "Zoomin" and "Zoomout" in the "SpatialToolStrip" I just got in (1)?

(3) I used to load the docx file of my DotSpatial-project screenshots to the site before. Recently, I found out that I cannot upload the content of the docx file of my DotSpatial-project screenshots to the site anymore!!  Is any different way to attach my DotSpatial-project screenshots to the post of this Discussions" site? 

Please kindly help and answer the above-mentioned questions and prblems.  Please, please, please respond and advise. 

Thanks in advance,

Scott Chang

Jul 30, 2012 at 4:55 PM

You can also try for sharing files.

If you are using the template you don't need a map or legend etc. You can just hit F5 (run) and they will be there. The template takes care of the plumbing.

Jul 30, 2012 at 7:12 PM

Hi Mudnug,  Thanks for your nice response.

(1) I clicked on F5 to run my project scDS1_ExpressWinForm1 and I got the following:

"NullReferenceException was unhandled" is pointing to "this.spatialToolStrip1.Map = null;"  (Line 38 of private void InitializeComponent() 

How can I resolve this problem?

 (2) After I launched the project "scDS1_ExpressWinForm1", I clicked on the Properties of  scDS1_ExpressWinForm1 and changed (i) the ".Net Framework 4 Client Profile" to the ".Net Framework 4" and (ii) Startup object: (Not set)  to "scDS1_ExpressWinForm1.Program" that is already listed below the (Not set) in the Startup object.  Did I do the right thing for (ii)?

Please kindly help and respond.

Thanks again,

Scott Chang

Jul 30, 2012 at 8:38 PM

1) you can remove spatialToolStrip1.

2) This sounds fine. You can also leave it as .Net Framework 4 Client Profile according to your preference.

Jul 31, 2012 at 1:02 PM

Hi Mudnug, Thanks for your nice, valuable response.

1) I launched a new project "scDS1-r_ExpressWinForm1", did "Add References" of System.ComponentModel.Composition and 13 dlls of your DotSpatial Plugin Template For VSexpressedtions, and left my project as .Net Framework 4 Client Profile.  Then I pressed "F5" button to run the project. It ran OK and Form1 appeared. But I did not see anything else (like spatialToolStrip, etc) on the Form1 for me to use? If I want to do your "Using PointSymbolizer on a DrawingLayer" to get a set of XY Coordinates for 8 points drawn on the Map of the Form1, how can I do that kind of Point features?  Please tell me what next thing to do to proceed the DotSpatial GIS programming to the next higher level.

2) Before I did the new project  "scDS1-r_ExpressWinForm1", I tried to open my old project "scDS1_ExpressWinForm1", that had ".Net Framework 4" in the Properties of the project and "spatialToolStrip1" on Form1 and it gave me the following Error: To prevent possible data loss before loading the designer, the following errors must be resolved: Object reference not set to an instance of an object. Instance of this error (1) 1. Show Call Stack. ...  I gave up on this old project and re-started a new project as mentioned in 1).   What is wrong in my old project "scDS1_ExpressWinForm1" that is using .Net Framework 4?

Please kind help and respond again.

Many Thanks,

Scott Chang  

Jul 31, 2012 at 4:58 PM

1) It turns out that express editions cannot start an alternate executable on  launch, so you will want to launch DemoMap.exe manually.

You will create a new class library (that compiles to a dll) based on MyPlugin1.cs and copy it's output (the dll) to a Plugins folder beside DemoMap.exe


2) I'm not sure.

Aug 1, 2012 at 2:35 PM

Hi Mudnug,  Thanks for your response.

I want to launch your DemoMap.exe manually. I have your DempMap.exe, "bin" folder, "obj" folder, "Properties" folder, and MyPlugin1 in my C:\TEMP\DotSpatial Plugin Template For VSexpresseditions that were downloaded and unzipped from But I don't to how to launch your DemoMap.exe program in the Visual C# 2010 Express that is housed in my PC that is part of Microsoft NT4 LAN Syste.   Please give me the detailed instructions of (i) launching your DemoMap.exe manually and (ii) creating a new class library (that compiles to a dll) based on MyPlugin1.cs and copy it's output (the dll) to a Plugins folder beside DemoMap.exe.

Thanks in advance,

Scott Chang