Opening MapWindow project in DotSpatial

Jan 16, 2013 at 10:52 AM
Edited Jan 16, 2013 at 1:26 PM

Hi everybody,
As a result of lack of documentation, I am guessing that DotSpatial.Plugins.MapWindowProjectFileCompatibility stands for compatibility between MapWindow 4.X and DotSpatial library.


So, my objective is to load a  MapWindow project into my application in order to read the layers style that have already been defined in the project.
But I'm not successfull using this plugin. It always throws exception: "Object reference not set to an instance of an object". Here's my code:

 

 

            OpenProjectMwprj project = new OpenProjectMwprj();
            try
            {
                project.Open("mapwin4project.mwprj");
            }

            catch (Exception e)
            {

            }

 

Any help? Thank you in advance.

 

EditI debugged the DotSpatial.Plugins.MapWindowProjectFileCompatibility.cs file and it seems that we're missing to initialize App property, which stands for AppManager object. I am not sure if that's the problem, or I am missing something else. If it is so, how do I initialize project.App ?

Edit1: Now I am able to read the project file, but still getting an error from the plugin library. It seems some kind of internal error using [] as indexer. 'mapa' is actually a Map Control.

 

 

            OpenProjectMwprj project = new OpenProjectMwprj();
            project.App = new AppManager();
            project.App.Map = mapa;
            try
            {
                project.Open("map4win.mwprj");
            }

            catch (Exception e)
            {

            }