0

I'm building an extension for a program (.NET Class library) where I want to use GDAL. I have installed GDAL and GDAL.Native via Nuget. I previously tested my function in a separate Console App, and everything was working fine.

But when I use the function in my Class Library and load it into the program, it's giving an error during the GdalConfiguration:

The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception. at OSGeo.GDAL.GdalPINVOKE.SetConfigOption(String jarg1, String jarg2) at OSGeo.GDAL.Gdal.SetConfigOption(String pszKey, String pszValue) at MyGdal.GdalConfiguration..cctor() in C:....MyGdal\GdalConfiguration.cs:line 98

In Line 98 the configuration for variable "GDAL_DATA" is set:

// Set the additional GDAL environment variables.
string gdalData = Path.Combine(gdalPath, "data");
Environment.SetEnvironmentVariable("GDAL_DATA", gdalData);
Gdal.SetConfigOption("GDAL_DATA", gdalData);

Does anyone know why this variable cannot be set when using the function in the program but it works when using it in a Console App? I have tried to reference the Console App to my Class Library and call the function from there, but it is giving te same error.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.