I have a "console" application where I installed the Nuget package "GDAL" (and also GDAL.Native).
Besides the exe file, this application also generates a dll that can be loaded as an addin in a third party software (Autocad).
- Case 1: if I run the
exefile, my application works and GDAL functions also work (this makes my question different from this one in the sense that a regular console application does work well, GDAL is doing it's job, the problem is specifically when it's working as an addin) - Case 2: if I load the
dllfile as an addin in the third party software, the addin works, but when it's time to call one of the GDAL functions (example:Gdal.Open(filePath, Access.GA_ReadOnly)), I get the following exception:
Exception: 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' or one of its dependencies: Não foi possível encontrar o módulo especificado. (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 ---
at OSGeo.GDAL.GdalPINVOKE.Open(Byte[] jarg1, Int32 jarg2)
at OSGeo.GDAL.Gdal.Open(String utf8_path, Access eAccess)
at ... my own code ...
I suspect Nuget packages might be configured with absolute pathes. Is there a way to make it use relative pathes instead? The gdal_wrap.dll existis and is being output.
Using the latest stable GDAL v3.11.3 Nuget packaged downloaded from Visual Studio 2022 (Version 17.14.17)