Sharpmap and Crystal Reports for VS2010 - conflict

Topics: SharpMap v0.9 / v1.x
Apr 15, 2011 at 8:38 AM

ERROR in VS 2010 Using SharpMap and Crystal Reps for VS 2010

 I have a VS2010 app that uses Sharp Map and Crystal Reps for VS 2010 – it was previously in VS 2005 with the Crystal Reps for VS 2005 version – Everything was working absolutely fine with this scenario, but now I have a continual error.

1.      If I start the app and run a crystal report – it works

2.      If I then start the Map (SharpMap) and try to load the aerial photo – I get the following error

  • The type initializer for ‘OSGEO.Gdal,Gdal.Pinvoke’ threw an exception – it happens on this line of code OSGEO.Gdal.Gdal.AllRegister() in SharpMap.Extensions\Layers\GdalRasterlayer.cs code

3.      However, if I restart my machine and go to the Map first and load the aerial photo, everything is OK

4.      If I then go and try and run a Crystal Report I get the following error

  • The type initializer for ‘CrystalDecision.CrystalReports.Engine.CRPE’ threw an exception – this happens on my line of code RepDoc.load(ReportPath)

5.      I have tried the above about 4 times and each time I would get the same result – I would have to reboot my machine to move between the 2 errors – this leads me to believe that these 2 pieces of software are somehow interfering with each other

Does anyone know how to resolve this?


Apr 15, 2011 at 10:35 AM

looks a CR-related problem, with no relations with sharpmap

Apr 15, 2011 at 10:50 AM

Sound like OSGEO.Gdal,Gdal and CR initializes some 3:d party unmanaged dll:s that are not compatible (probably for TIFF libraries? or what format is your aerial photo stored in?)

Apr 15, 2011 at 11:38 AM

Since sharpmap v0.9's GdalRasterLayer relies on FWTools 2.4.7, which is fairly old, you may succeed by installing a newer version of gdal (1.8 is out) and replacing the csharp bindings.

You can find a new version of gdal at

Hth FObermaier