Jan 3, 2014 at 11:03 AM
Edited Jan 5, 2014 at 12:07 PM
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"))
SharpMap.Layers.GdalRasterLayer layer = new GdalRasterLayer(
catch (Exception ex)
I have tried it with both the OS 1:250k Raster images and the images supplied in the example section of the trunk. Could it be something to do with the projections, I have set it on the LayerGroup and Layer and still no luck.
Any ideas gratefully received.
I have managed to create a winforms application and got it working. I have recreated it in a new MVC4 & 5 Web Application and I am still getting the same error. So it must be something to do with it being in a MVC project and not winforms.