I have installed GDAL and GDAL.Native v3.9.1 packages. Console application works well.
But when I use it in AutoCAD Class Library project, it always raise the exception
The type initializer for ‘OSGeo.GDAL.GdalPINVOKE’ threw an exception.
I am using Visual Studio 2019. The application is being compiled using .NetFramework 4.8.1 .
The default GdalConfiguration.cs file is set with execution path of output directory where gdal folder is installed.
// Add directories
AddDllDirectory(nativePath);
AddDllDirectory(Path.Combine(nativePath, "plugins"));
// Set the additional GDAL environment variables.
string gdalData = Path.Combine(gdalPath, "data");
Environment.SetEnvironmentVariable("GDAL_DATA", gdalData);
** Gdal.SetConfigOption("GDAL_DATA", gdalData);**
string driverPath = Path.Combine(nativePath, "plugins");
Environment.SetEnvironmentVariable("GDAL_DRIVER_PATH", driverPath);
** Gdal.SetConfigOption("GDAL_DRIVER_PATH", driverPath);**
The highlighted bold lines generates the exception.
Any idea to counter this issue ?
Thanks
I tried to ask for the help
Imran Anees is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.