Search code examples
gdal

Exception Using GDAL in WCF Rest Service


I am developing a WCF REST service (.net 4) that uses the GDAL libraries. It works great on my development machine but throws an exception on the server (Windows Server 2008 R2). The code fails at

OSGeo.GDAL.Gdal.AllRegister();

Here's the exception:

20130214081020 Exception Message: The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception.
20130214081020 Exception Stack Trace:    at OSGeo.GDAL.GdalPINVOKE.AllRegister()
   at OSGeo.GDAL.Gdal.AllRegister()
   at RasterValues.GetDemElevation(String latitude, String longitude)
20130214081020 Inner exception Message: The type initializer for 'SWIGExceptionHelper' threw an exception.
20130214081020 Inner exception stack trace:    at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..ctor()
   at OSGeo.GDAL.GdalPINVOKE..cctor()

I have copied the GDAL files to the server and have added the path to those in the PATH environment variable.

Any thoughts on what I'm missing? Thanks!


Solution

  • It turns out that I needed to add the *_wrap.dll files to the bin folder of my service.