This project has moved. For the latest updates, please go here.

Cannot find gdal_wrap.dll

Topics: SharpMap Project
May 5, 2014 at 10:05 AM
Hi All

This is not the obvious problem of not having DLLs in the path - I worked my way through that.
I have installed packages into VS using NuGet for GDAL and GDAL.Native and got the following code to work fine:
var layer = new SharpMap.Layers.GdalRasterLayer(file, file);
However, if I put this code in the same method:
var gdalDataset = Gdal.Open(file, Access.GA_ReadOnly);
then I get this exception:

!!!Suppressed!!! System.TypeInitializationException: The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'gdal_wrap': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_Gdal(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..cctor()
--- End of inner exception stack trace ---
at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..ctor()
at OSGeo.GDAL.GdalPINVOKE..cctor()
--- End of inner exception stack trace ---

....which is what I used to get before I correctly made DLLs available in the path. So since GdalRasterLayer() is able to find gdal_wrap without difficulty, why does Gdal.Open() have a problem...?