Catching PINVOKE exception from loaded assembly

@Alain, @dale, @stevebaer, @will I am experiencing the same problem with the same library, and the solution given by @menno doesn’t work in my case, I have tried to copy the dll’s inside the same folder as the plugin and after encapsulating the:

GdalConfiguration.ConfigureOgr();

GdalConfiguration.ConfigureGdal();

calls in a try catch, I am seeing:

Exception caught. System.TypeInitializationException: Se produjo una excepción en el inicializador de tipo de 'ReadGribFiles.GdalConfiguration'. ---> System.TypeInitializationException: Se produjo una excepción en el inicializador de tipo de 'OSGeo.GDAL.GdalPINVOKE'. ---> System.TypeInitializationException: Se produjo una excepción en el inicializador de tipo de 'SWIGExceptionHelper'. ---> System.DllNotFoundException: No se puede cargar el archivo DLL 'gdal_wrap': No se puede encontrar el módulo especificado. (Excepción de HRESULT: 0x8007007E)
   en 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)
   en OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..cctor()
   --- Fin del seguimiento de la pila de la excepción interna ---
   en OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..ctor()
   en OSGeo.GDAL.GdalPINVOKE..cctor()
   --- Fin del seguimiento de la pila de la excepción interna ---
   en OSGeo.GDAL.GdalPINVOKE.SetConfigOption(String jarg1, String jarg2)
   en OSGeo.GDAL.Gdal.SetConfigOption(String pszKey, String pszValue)
   en ReadGribFiles.GdalConfiguration..cctor()
   --- Fin del seguimiento de la pila de la excepción interna ---
   en ReadGribFiles.GdalConfiguration.ConfigureOgr()
   en ReadGribFiles.ReadGribFiles.SolveInstance(IGH_DataAccess DA)