SharpMap -Gdal Raster Layer, The type initializer for 'SharpMap.Layers.GdalRasterLayer' threw an exception

1.7k views Asked by At

I am trying to create a rasterlayer from the example geotiffs. I have downloaded the GDAL native and plugins NuGets. However whenever I run the project it always returns a not very helpful error: "The type initializer for 'SharpMap.Layers.GdalRasterLayer' threw an exception."

I know the sharp map elements are working as I can load in a vector layer and display it no problem its just the GDAL side.

This is the code I am using. I have checked and the GDAL directories are included in the bin folder when running.

LayerGroup group = new LayerGroup("OS");
        //group.SRID = 27700;
        group.LayerName = "Raster250";

        var di = new DirectoryInfo(@"C:\OS Maps Current\GeoTiff");
        foreach (var fi in di.GetFiles("*.tif"))
        {
            try
            {
                SharpMap.Layers.GdalRasterLayer layer = new GdalRasterLayer(
                    fi.Name, fi.FullName);
                group.Layers.Add(layer);
            }
            catch (Exception ex)
            {
            }
        }

        m_Map.Layers.Add(group);

Any ideas gratefully received.

Chris

0

There are 0 answers