Problem with SharpMAp ORG provider

Topics: Data Access, SharpMap v0.9 / v1.x, WinForms Controls
Jan 29, 2012 at 1:28 PM

hello  all
I'm working on a GIS project that I want to use with MapInfo and Sharpmap ORG  provider I did this code 

 SharpMap.Map mymap = new SharpMap.Map(mapimage1.Size);
            SharpMap.Layers.VectorLayer vLayer = new SharpMap.Layers.VectorLayer("OgrSample");
            try
            {
                vLayer.DataSource = new SharpMap.Data.Providers.Ogr(@"C:\Users\Sam\Downloads\algermapinfo\algermapinfo\C_ALGER.TAB");
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }

            mymap.Layers.Add(vLayer);
            mymap.ZoomToExtents();
            mapimage1.Map = mymap;
 but I have this nice exception

---------------------------System.TypeInitializationException: Une exception a été levée par l'initialiseur de type pour 'SharpMap.Data.Providers.Ogr'. ---> System.TypeInitializationException: Une exception a été levée par l'initialiseur de type pour 'SharpMap.Extensions.Data.FwToolsHelper'. ---> SharpMap.Extensions.Data.FwToolsHelper+FwToolsPathException: '' is an Invalid Path to FWTools2.4.7. Create an application setting in [app|web].config key='FWToolsBinPath' pointing to the bin directory of FWTools2.4.7 (absolute file path) . FWTools is downloaded from http://home.gdal.org/fwtools/
   à SharpMap.Extensions.Data.FwToolsHelper..cctor() dans C:\Users\Sam\Desktop\Tags\v0.9\2011-11-13\SharpMap.Extensions\Data\FwToolsHelper.cs:ligne 32
   --- Fin de la trace de la pile d'exception interne ---
   à SharpMap.Extensions.Data.FwToolsHelper.Configure()
   à SharpMap.Data.Providers.Ogr..cctor() dans C:\Users\Sam\Desktop\Tags\v0.9\2011-11-13\SharpMap.Extensions\Data\Providers\OgrProvider.cs:ligne 53
   --- Fin de la trace de la pile d'exception interne ---
   à SharpMap.Data.Providers.Ogr..ctor(String datasource)
   à testORG.Form1.Form1_Load(Object sender, EventArgs e) dans E:\Learings\EF\testORG\testORG\Form1.cs:ligne 25---------------------------OK   ---------------------------

Coordinator
Jan 31, 2012 at 9:39 AM

The solution to your problem is clearly stated in the exception message:

'' is an Invalid Path to FWTools2.4.7. Create an application setting in [app|web].config key='FWToolsBinPath' pointing to the bin directory of FWTools2.4.7 (absolute file path) . FWTools is downloaded from http://home.gdal.org/fwtools/

So you need to

  • download FWTools 2.4.7 and install that on your machine,
  • modify your app|web.config (see this)

Hth FObermaier


Jan 31, 2012 at 10:43 AM

cool thank's