MaxRev-Dev / gdal.netcore

GDAL 3.x C#/F# bindings for .NET apps
MIT License
161 stars 36 forks source link

[BUG] 3.9.1 fails to run in Azure VM - Unable to load DLL 'gdal_wrap' or one of its dependencies #143

Closed OWiger closed 3 months ago

OWiger commented 3 months ago

I'm also having this issue with loading the native dll's.

I'm building a simple .NET 8.0 Console application with MaxRev.Gdal.Core (3.9.1.244) and MaxRev.Gdal.WindowsRuntime.Minimal (3.9.1.244).

Program.cs: using MaxRev.Gdal.Core; GdalBase.ConfigureAll(); Console.WriteLine("Hello, World!");

I build this project in release mode. On my dev-machine, it works fine. Hello world is displayed.

If I copy the entire net8.0 output folder to a freshly created azure VM with Windows 11 (or windows 10), and try to run the application I get: 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) 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.AllRegister() at OSGeo.GDAL.Gdal.AllRegister() at MaxRev.Gdal.Core.GdalBase.ConfigureGdalDrivers(String gdalDataFolder) at MaxRev.Gdal.Core.GdalBase.ConfigureAll() at Program.<Main>$(String[] args) in C:\Users\ow\source\repos\TestGdalApp\Program.cs:line 4

I have the following runtimes and redistributables installed on the vm:

image

Here's the contents of my native-folder: ` Directory of C:\Users\win11test\Desktop\net8.0\runtimes\win-x64\native

Details

08/13/2024 11:51 AM

. 08/13/2024 11:50 AM .. 08/11/2024 10:57 PM 69,632 blosc.dll 08/11/2024 10:53 PM 137,728 brotlicommon.dll 08/11/2024 10:53 PM 50,688 brotlidec.dll 08/11/2024 10:53 PM 3,344,384 brotlienc.dll 01/23/2022 01:05 PM 1,379,840 cfitsio.dll 08/08/2024 05:54 AM 322,560 concrt140.dll 10/03/2023 08:35 AM 143,360 freexl.dll 08/11/2024 11:18 PM 22,384,128 gdal.dll 08/11/2024 11:18 PM 43,520 gdalconst_wrap.dll 08/11/2024 11:18 PM 133,632 gdal_wrap.dll 08/11/2024 10:48 PM 2,006,528 geos.dll 08/11/2024 10:48 PM 384,512 geos_c.dll 08/11/2024 10:53 PM 36,352 gif.dll 04/28/2024 10:39 PM 720,896 hdf.dll 04/28/2024 10:42 PM 3,342,336 hdf5.dll 04/28/2024 10:43 PM 121,344 hdf5_hl.dll 08/11/2024 10:53 PM 45,568 hwy.dll 08/11/2024 10:53 PM 1,076,736 iconv-2.dll 08/11/2024 10:49 PM 678,912 jpeg62.dll 08/11/2024 10:56 PM 2,515,968 jxl.dll 08/11/2024 10:54 PM 94,208 jxl_cms.dll 08/11/2024 10:56 PM 25,088 jxl_threads.dll 08/11/2024 10:53 PM 358,912 lcms2.dll 04/28/2024 10:19 PM 4,871,680 libcrypto-3-x64.dll 08/11/2024 10:50 PM 570,880 libcurl.dll 02/03/2022 09:16 PM 151,552 libexpat.dll 08/11/2024 10:49 PM 187,904 liblzma.dll 04/28/2024 10:36 PM 6,914,048 libmysql.dll 08/11/2024 10:54 PM 202,240 libpng16.dll 04/28/2024 10:28 PM 305,152 LIBPQ.dll 08/11/2024 10:49 PM 26,112 libsharpyuv.dll 04/28/2024 10:19 PM 1,256,448 libssl-3-x64.dll 08/11/2024 10:49 PM 373,760 libwebp.dll 04/28/2024 10:28 PM 1,431,040 libxml2.dll 08/11/2024 10:53 PM 121,344 lz4.dll 08/13/2024 11:50 AM maxrev.gdal.core.libshared 04/28/2024 10:39 PM 140,288 mfhdf.dll 08/08/2024 05:54 AM 575,056 msvcp140.dll 08/08/2024 05:54 AM 35,808 msvcp140_1.dll 08/08/2024 05:54 AM 268,880 msvcp140_2.dll 08/08/2024 05:54 AM 50,664 msvcp140_atomic_wait.dll 08/08/2024 05:54 AM 31,744 msvcp140_codecvt_ids.dll 04/28/2024 10:46 PM 1,108,480 netcdf.dll 08/11/2024 11:18 PM 105,472 ogr_wrap.dll 04/28/2024 10:36 PM 313,344 openjp2.dll 08/11/2024 11:18 PM 61,440 osr_wrap.dll 04/28/2024 10:53 PM 107,520 pcre.dll 04/28/2024 10:32 PM 3,305,472 proj_9_3.dll 08/11/2024 11:02 PM 3,353,600 proj_9_4.dll 04/28/2024 10:35 PM 13,557,248 spatialite.dll 08/11/2024 10:51 PM 1,108,992 sqlite3.dll 04/28/2024 10:37 PM 51,712 szip.dll 08/11/2024 10:50 PM 469,504 tiff.dll 08/08/2024 05:54 AM 351,824 vccorlib140.dll 08/08/2024 05:54 AM 119,888 vcruntime140.dll 08/08/2024 05:54 AM 49,640 vcruntime140_1.dll 08/08/2024 05:54 AM 38,504 vcruntime140_threads.dll 04/28/2024 10:39 PM 14,336 xdr.dll 01/23/2022 12:27 PM 2,785,792 xerces-c_3_2.dll 04/28/2024 10:08 PM 84,480 zlib.dll 08/11/2024 10:49 PM 90,624 zlib1.dll 08/11/2024 10:50 PM 653,824 zstd.dll 61 File(s) 84,663,128 bytes 3 Dir(s) 112,077,766,656 bytes free `

Environment information:

OWiger commented 3 months ago

Downgrading to version 3.8.3.286 works though. Then I get more files copied to my native folder:

Details

`08/13/2024 12:30 PM

. 08/13/2024 12:30 PM .. 02/03/2022 09:30 PM 44,032 adrg.dll 01/23/2022 03:46 PM 33,792 apr_dbd_odbc-1.dll 01/23/2022 03:46 PM 14,848 apr_ldap-1.dll 01/23/2022 01:24 PM 3,076,096 cairo.dll 01/23/2022 01:05 PM 1,379,840 cfitsio.dll 11/22/2023 03:27 AM 322,640 concrt140.dll 07/26/2017 09:01 AM 12,027,376 FileGDBAPI.dll 10/03/2023 08:35 AM 143,360 freexl.dll 01/23/2022 01:24 PM 114,688 fribidi-0.dll 02/05/2022 06:43 PM 819,712 fts5.dll 01/26/2024 01:22 PM 24,625,152 gdal.dll 01/26/2024 01:22 PM 35,328 gdalconst_wrap.dll 01/26/2024 01:22 PM 130,560 gdal_wrap.dll 03/15/2022 03:36 PM 1,900,544 geos.dll 03/15/2022 03:36 PM 358,400 geos_c.dll 01/23/2022 12:52 PM 719,360 hdf.dll 01/23/2022 12:59 PM 3,332,096 hdf5.dll 01/23/2022 01:00 PM 288,256 hdf5_cpp.dll 01/23/2022 01:03 PM 120,832 hdf5_hl.dll 01/23/2022 01:03 PM 14,848 hdf5_hl_cpp.dll 01/23/2022 12:18 PM 1,022,976 iconv-2.dll 01/24/2024 03:27 AM 807,936 jpeg62.dll 01/23/2022 03:46 PM 200,192 libapr-1.dll 01/23/2022 03:46 PM 159,744 libaprutil-1.dll 01/23/2022 11:19 AM 2,882,048 libcrypto-1_1-x64.dll 01/23/2022 11:29 AM 470,016 libcurl.dll 02/03/2022 09:16 PM 151,552 libexpat.dll 03/18/2022 04:54 PM 40,960 libfcgi.dll 01/23/2022 03:52 PM 445,952 libhttpd.dll 01/23/2022 01:06 PM 373,248 libkea.dll 01/24/2024 03:27 AM 185,856 liblzma.dll 01/23/2022 12:35 PM 3,681,792 libmysql.dll 01/23/2022 11:31 AM 196,608 libpng16.dll 02/05/2022 04:50 PM 305,152 libpq.dll 03/15/2022 03:45 PM 658,432 librttopo.dll 01/24/2024 03:27 AM 23,040 libsharpyuv.dll 01/23/2022 11:20 AM 688,640 libssl-1_1-x64.dll 01/24/2024 03:27 AM 371,712 libwebp.dll 01/24/2024 03:27 AM 160,256 libwebpdecoder.dll 01/24/2024 03:27 AM 20,480 libwebpdemux.dll 01/24/2024 03:27 AM 40,960 libwebpmux.dll 01/23/2022 12:19 PM 1,437,184 libxml2.dll 01/26/2024 11:59 AM 1,120,256 mapcache.dll 01/26/2024 11:59 AM 4,900,352 mapserver.dll 08/13/2024 12:30 PM maxrev.gdal.core.libshared 01/23/2022 12:52 PM 139,776 mfhdf.dll 01/26/2024 11:59 AM 19,456 mod_mapcache.dll 01/26/2024 11:59 AM 49,664 msplugin_mssql2008.dll 01/26/2024 11:59 AM 61,952 msplugin_oracle.dll 11/22/2023 03:27 AM 573,008 msvcp140.dll 11/22/2023 03:27 AM 35,920 msvcp140_1.dll 11/22/2023 03:27 AM 268,264 msvcp140_2.dll 11/22/2023 03:27 AM 50,256 msvcp140_atomic_wait.dll 11/22/2023 03:27 AM 31,848 msvcp140_codecvt_ids.dll 01/06/2021 10:39 AM 7,126,040 NCSEcw.dll 03/15/2022 03:55 PM 1,114,624 netcdf.dll 02/03/2022 09:30 PM 126,464 ogdi.dll 01/26/2024 01:22 PM 101,888 ogr_wrap.dll 10/03/2023 08:21 AM 313,856 openjp2.dll 01/26/2024 01:22 PM 58,880 osr_wrap.dll 01/23/2022 03:49 PM 107,520 pcre.dll 01/23/2022 03:49 PM 52,224 pcrecpp.dll 01/23/2022 03:50 PM 12,800 pcreposix.dll 01/23/2022 11:26 AM 327,168 proj_4_9.dll 02/05/2022 06:48 PM 2,867,712 proj_7_2.dll 10/03/2023 07:59 AM 3,251,712 proj_9_1.dll 01/26/2024 01:16 PM 3,319,808 proj_9_3.dll 02/03/2022 09:30 PM 39,936 remote.dll 02/03/2022 09:30 PM 67,072 rpf.dll 02/03/2022 09:30 PM 34,816 skeleton.dll 10/03/2023 08:36 AM 13,536,768 spatialite.dll 02/05/2022 06:43 PM 2,438,656 sqlite3.dll 01/23/2022 12:48 PM 51,200 szip.dll 10/03/2023 08:16 AM 1,341,440 tiff.dll 10/03/2023 07:57 AM 9,728 tiffxx.dll 01/24/2024 03:27 AM 943,104 turbojpeg.dll 11/22/2023 03:27 AM 348,784 vccorlib140.dll 11/22/2023 03:27 AM 119,376 vcruntime140.dll 11/22/2023 03:27 AM 49,776 vcruntime140_1.dll 11/22/2023 03:27 AM 38,480 vcruntime140_threads.dll 02/03/2022 09:30 PM 195,072 vrf.dll 01/23/2022 12:52 PM 13,824 xdr.dll 01/23/2022 12:27 PM 2,785,792 xerces-c_3_2.dll 01/23/2022 11:10 AM 86,528 zlib.dll 01/24/2024 03:27 AM 89,600 zlib1.dll 01/23/2022 11:30 AM 723,968 zstd.dll 85 File(s) 112,771,864 bytes 3 Dir(s) 111,680,712,704 bytes free C:\Users\win11test\Desktop\net8.0\runtimes\win-x64\native>`

MaxRev-Dev commented 3 months ago

@OWiger The previous version contains all drivers from SDK and VCPKG, even they are not utilised during the runtime. Starting the 3.9.1 version all required dependencies are being collected by a script.

I need more info to investigate this. Please, install and open Git Bash and run ldd gdal.dll (usually it's located in bin/<Configuration>/net8.0/runtimes/win-x64/native). For example: ldd bin/Release/net8.0/runtimes/win-x64/native/gdal.dll

MaxRev-Dev commented 3 months ago

Installed a fresh Win10 on VM and found a missing driver. Let me know if these artifacts work for you (try with local restore) https://github.com/MaxRev-Dev/gdal.netcore/actions/runs/10375191648/artifacts/1808132653

OWiger commented 3 months ago

Installed a fresh Win10 on VM and found a missing driver. Let me know if these artifacts work for you (try with local restore) https://github.com/MaxRev-Dev/gdal.netcore/actions/runs/10375191648/artifacts/1808132653

Yes, this works! Thank you!