[BUG] windows server 2022 - unable to load gdal_wrap
Hello there :-)
I have an ASP.NET WEB API c# project using gdal which includes :
- MaxRev.Gdal.Core
- MaxRev.Gdal.WindowsRuntime.Minimal
- MaxRev.Gdal.LinuxRuntime.Minimal.x64
I tried both 3.9.1.246 and 3.9.1.247 (both failed).
I publish it through Visual studio with these parameters:
- configuration : release any cpu
- target framework : net8.0
- deployemend mode : self-contained
- target runtime: win-x64
the project runs fine on :
- windows 11 (24H2 26120.1542)
- docker (under ubuntu 24)
output :
\bin\Release\net8.0\publish> dotnet .\test.Host.dll About OS: Microsoft Windows 10.0.26120 OS Architecture: X64 Runtime Identifier: win-x64 Working directory: *****test.Host\bin\Release\net8.0\publish Trying to configure all twice GDAL configured OGR Vector Drivers: 81 GDAL Raster Drivers: 150 Package version: 3.9.1.247 GDAL Version: 3.9.1 GDAL INFO: GDAL 3.9.1, released 2024/08/14 ... ... (all loading) ... Test string: "AAIGrid","ACE2","ADRG","AIG","AirSAR","AmigoCloud","AVCBin","AVCE00","BAG","BIGGIF","BLX","BMP","BSB","BT","BYN","CAD","CALS","Carto","CEOS","COASP","COG","COSAR","CPG","CSV","CSW","CTable2","CTG","DAAS","DERIVED","DGN","DIMAP","DIPEx","DOQ1","DOQ2","DTED","DXF","ECRGTOC","EDIGEO","EEDA","EEDAI","EHdr","EIR","ELAS","Elasticsearch","ENVI","ERS","ESAT","ESRI Shapefile","ESRIC","ESRIJSON","FAST","FIT","FITS","FlatGeobuf","GenBin","Geoconcept","GeoJSON","GeoJSONSeq","GeoRSS","GFF","GIF","GML","GMLAS","GNMDatabase","GNMFile","GPKG","GPSBabel","GPX","GRASSASCIIGrid","GRIB","GS7BG","GSAG","GSBG","GSC","GTFS","GTI","GTiff","GTX","GXF","HDF4","HDF4Image","HDF5","HDF5Image","HF2","HFA","HTTP","Idrisi","ILWIS","Interlis 1","Interlis 2","IRIS","ISCE","ISG","ISIS2","ISIS3","JAXAPALSAR","JDEM","JML","JP2OpenJPEG","JPEG","JPEGXL","JSONFG","KML","KMLSUPEROVERLAY","KRO","L1B","LAN","LCP","Leveller","LIBKML","LOSLAS","LVBAG","MAP","MapInfo File","MapML","MBTiles","MEM","Memory","MFF","MFF2","MiraMonVector","MRF","MSGN","MSSQLSpatial","MVT","MySQL","NAS","NDF","netCDF","NGSGEOID","NGW","NITF","NOAA_B","NSIDCbin","NTv2","NWT_GRC","NWT_GRD","OAPIF","ODBC","ODS","OGCAPI","OGR_GMT","OGR_PDS","OGR_SDTS","OGR_VRT","OpenFileGDB","OSM","OZI","PAux","PCIDSK","PCRaster","PDF","PDS","PDS4","PGDUMP","PGeo","PLMOSAIC","PLSCENES","PMTiles","PNG","PNM","PostGISRaster","PostgreSQL","PRF","R","Rasterlite","RIK","RMF","ROI_PAC","RPFTOC","RRASTER","RS2","RST","S102","S104","S111","S57","SAFE","SAGA","SAR_CEOS","SDTS","Selafin","SENTINEL2","SGI","SIGDEM","SNODAS","SQLite","SRP","SRTMHGT","STACIT","STACTA","SVG","SXF","Terragen","TGA","TIGER","TIL","TopoJSON","TSX","UK .NTF","USGSDEM","VDV","VFK","VICAR","VRT","WAsP","WCS","WEBP","WFS","WMS","WMTS","XLS","XLSX","XPM","XYZ","Zarr","ZMap" Drivers:217
the project crashes on windows server 2022 (21H2 20348.2655 OR 20348.2461).
dotnet .\test.Host.dll About OS: Microsoft Windows 10.0.20348 OS Architecture: X64 Runtime Identifier: win-x64 Working directory: ******\publish Trying to configure all twice 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: A dynamic link library (DLL) initialization routine failed. (0x8007045A) 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 WebAero.Web.Scheduler.Host.Startup.Program.Main(String[] args) in ****test.Host\Startup\Program.cs:line 31
the file gdal_wrap.dll is already in the folder; do you have any idea on what i do wrong ? :) Thanks a lot for your help !
I tried to repro this. My build works without any issues. The environment is plain Windows Server 2022 with Git and Dotnet8 installed. The self-contained app works as well.
Could you please post a MRE if available. Also you can try to run LDD from GitBash. See this comment for details https://github.com/MaxRev-Dev/gdal.netcore/issues/143#issuecomment-2286585656
Thanks for info.
I have recreated a Windows Server 2022 eval from scratch, to have the same version as you (cf screenshot). It is a virtual machine running under proxmox VE 8.
Then i have generated a MRE project as minimal as possible to reproduce the same behavior (it is ok on win 11 but not win 2022). I Have set the full project (+ publish folder) on my onedrive : https://1drv.ms/f/s!Agg2DlhA4TQqjZRlu-xnv_DtLU1siA?e=lItaIO
for the LDD git bash, i can run it on the project .dll but when i try to use it on gdal.dll or gdal_wrap.dll, it keeps running for few hours without displaying any output. do you know if it is the normal behavior ?
Since we use the exact same version of SRV2022 EVAL (without any modification), i think we can skip this issue. Maybe it is either related to the virtual machine itself, or the project. But the project with older version of GDAL (offical one) without moving to maxrev.gdal.core was working on the SRV2022 server.
any idea ? :)
I am experiencing something very similar. But I am not even getting it to work on Windows 10.
I have the following installed: maxRev.Gdal.Core 3.9.1.247 maxRev.Gdal.Universal 3.9.1.247 maxRev.Gdal.WindowsRuntime.Minimal 3.9.1.247
We found that this seems to be missing as a dependency of gdal_wrap.dll. I am not sure if this is exactly the same issue as stated above, otherwise I can also open a new issue. But it seems very similar. @MaxRev-Dev I am not sure if you can reproduce this and maybe this fix via this issue already.
Here is my error code. For what I can see exactly the same as the error message that @dawsidious received.
System.TypeInitializationException
The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception.
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 AiChangeDetectionModel.Services.AiChangeDetectionModelService.SaveArrayTif(DenseTensor1 imgArrayOutput, String name, ValueTuple2 upperLeft) in C:\DevOpsIT\GIS.Viewer\BorePlannerZonderBP\src\AiChangeDetectionModel\Services\AiChangeDectectionModelService.cs:line 158
at AiChangeDetectionModel.Services.AiChangeDetectionModelService.Run() in C:\DevOpsIT\GIS.Viewer\BorePlannerZonderBP\src\AiChangeDetectionModel\Services\AiChangeDectectionModelService.cs:line 66
at AiChangeDetectionModel.Tests.AiChangeDetectionModelServiceTests.TestRunAiChangeDetectionModel() in C:\DevOpsIT\GIS.Viewer\BorePlannerZonderBP\src\AiChangeDetectionModel.Tests\AiChangeDetectionModelServiceTests.cs:line 11
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
at Xunit.Sdk.AsyncTestSyncContext.<>c__DisplayClass7_0.<Post>b__0() in /_/src/xunit.execution/Sdk/AsyncTestSyncContext.cs:line 58
System.TypeInitializationException The type initializer for 'SWIGExceptionHelper' threw an exception. at OSGeo.GDAL.GdalPINVOKE.SWIGExceptionHelper..ctor() at OSGeo.GDAL.GdalPINVOKE..cctor()
System.DllNotFoundException Unable to load DLL 'gdal_wrap' or one of its dependencies: The specified procedure could not be found. (0x8007007F) 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()
@dawsidious I took me a while. I have installed VirtualBox and with the same configuration I have a repro. I suppose it's missing instructions in VM, because if falls down to kernel on profiling via dependency walker while having the identical set of dependencies and same OS configuration (almost). ~It can be~ a missing AVX2 instruction.
It's 100% missing AVX2, I have tested with disabled Hyper-V.
I can't test it currently but recommend you to try disabling Hyper-V and this will enable AVX/AVX2 instructions in your VM. OR use Hyper-V managed virtual machine.
Edit: I had to disable Core Isolation > Memory Integrity to force turn off Hyper-V.
Closing due to inactivity.