[BUG] MSSQL driver is not available in windows runtime
Describe the bug Unhandled 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: The specified module could not be found. (0x8007007E)
To Reproduce < Steps to reproduce the behavior: >
Expected behavior Run without issue
Screenshots
Environment information:
- Windows 10 Enterprise [22H2]
- Package version (core): [3.9.0.218]
- Package version (runtime): [3.9.0.218]
Additional context It worked fine with version 3.8.3.259. I got this error when I upgraded the packages. I did try reinstalling the packages but had no luck.
@MukeZ Could you run ldd from git bash on gdal.dll in the output directory (usually bin/<Configuration>/net8.0/runtimes/win-x64/native)?
For example: ldd bin/Release/net8.0/runtimes/win-x64/native/gdal.dll
+1 This is a regression in one or both of MaxRev.Gdal.Core and MaxRev.Gdal.WindowsRuntime.Minimal 3.9.0.218, with hitting a gdal.dll dependency on msodbcsql17.dll looking like the most likely cause from what I have at the moment. The 3.8.3.286 builds of the packages work fine so main workaround here's probably just rolling back.
ldd is a Linux tool. The Windows equivalent's dumpbin /dependents, though Visual Studio only drops it if MSVC build tools are installed and thus C# devs may well not have it.
net8.0\runtimes\win-x64\native>"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\dumpbin.exe" /dependents gdal_wrap.dll
Image has the following dependencies:
gdal.dll [present in win-x64\native]
MSVCP140.dll [present in win-x64\native]
VCRUNTIME140.dll [present in win-x64\native]
VCRUNTIME140_1.dll [present in win-x64\native]
api-ms-win-crt-runtime-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-string-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-heap-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
KERNEL32.dll [in %SystemRoot%\System32]
runtimes\win-x64\native>"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\dumpbin.exe" /dependents gdal.dll
Image has the following dependencies:
ODBC32.dll [in %SystemRoot%\System32]
libxml2.dll [present in win-x64\native]
libcrypto-3-x64.dll [present in win-x64\native]
libssl-3-x64.dll [present in win-x64\native]
CRYPT32.dll [in %SystemRoot%\System32]
liblzma.dll [present in win-x64\native]
lz4.dll [present in win-x64\native]
blosc.dll [present in win-x64\native]
libexpat.dll [present in win-x64\native]
xerces-c_3_2.dll [present in win-x64\native]
tiff.dll [present in win-x64\native]
WS2_32.dll [in %SystemRoot%\System32]
libpng16.dll [present in win-x64\native]
zstd.dll [present in win-x64\native]
gif.dll [present in win-x64\native]
netcdf.dll [present in win-x64\native]
cfitsio.dll [present in win-x64\native]
hdf5.dll [present in win-x64\native]
sqlite3.dll [present in win-x64\native]
LIBPQ.dll [present in win-x64\native]
openjp2.dll [present in win-x64\native]
jxl.dll [present in win-x64\native]
jxl_threads.dll [present in win-x64\native]
pcre.dll [present in win-x64\native]
spatialite.dll [present in win-x64\native]
libmysql.dll [present in win-x64\native]
msodbcsql17.dll
freexl.dll [present in win-x64\native]
geos_c.dll [present in win-x64\native]
proj_9_4.dll [present in win-x64\native, along with older versions 4.9, 7.2, 9.1, and 9.3]
libcurl.dll [present in win-x64\native]
iconv-2.dll [present in win-x64\native]
hdf.dll [present in win-x64\native]
mfhdf.dll [present in win-x64\native]
KERNEL32.dll [in %SystemRoot%\System32]
USER32.dll [in %SystemRoot%\System32]
ole32.dll [in %SystemRoot%\System32]
OLEAUT32.dll [in %SystemRoot%\System32]
ADVAPI32.dll [in %SystemRoot%\System32]
MSVCP140.dll [present in win-x64\native]
VCRUNTIME140.dll [present in win-x64\native]
VCRUNTIME140_1.dll [present in win-x64\native]
api-ms-win-crt-heap-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-utility-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-stdio-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-runtime-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-string-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-math-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-convert-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-time-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-environment-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-locale-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
api-ms-win-crt-filesystem-l1-1-0.dll [in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\{IDE, Tools}]
zlib.dll [present in win-x64\native]
@twest820 Regarding ldd: Yes, it is. But ldd is available in Git Bash and it shows resolved paths. So it comes with Git (Usually everyone has it). The dumpbin utility is good as well, but it's not that detailed and as you mentioned it requires VS tools installation.
Anyways, it looks like MSSQL driver is not being copied to the output on windows, and I see it's available in CI and my PC. This should be fixed with a patch.
Cool, thanks.
(The most common method I'm aware of for getting to a git command line with Visual Studio is Git -> Open in Command Prompt. I think Visual Studio does use the Git for Windows installer, which drops Git Bash, but it's likely many Windows + Visual Studio users won't be aware VS installs it or that Git Bash is mingw64 based and picks up ldd via that. Also, as with MSVC tools, git isn't a required VS component. Though, yeah, if you're posting on GitHub probably you're using git somehow.)