3

I have created a C# WPF (.NET Framework 4.6.1) application in Visual Studio 2017 and installed latest stable GDAL 2.4.2 from Nuget.

In the App.xaml I have added the GDAL configuration call:

protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);

    GdalConfiguration.ConfigureGdal();
}

When I build the application I get the following error:

“error CS0103: The name 'GdalConfiguration' does not exist in the current 
context”

I have located the GdalConfiguration.cs file in the subfolder

obj\Debug\NuGet\15f0ca2b5ecbe407152208e918cf2c4389b630a2\GDAL\2.4.2

and pressing F12 on GdalConfiguration.ConfigureGdal() opens up that specific file.

Question:

Do I have to do anything else to be able to use GDAL in my application?

1
  • As per the Tour there should be only one question asked per question.
    – PolyGeo
    Oct 28 '19 at 6:56
0

My Visual Studio 2019 with NuGet package GDAL v2.4.4 by Tamas Szekeres doesn't find that class during build time either despite it being found by Visual Studio itself, as you say. I can also see it in the folder you point out.

I ended up using this autogenerated helper function as a replacement OSGeo.GDAL.Gdal.AllRegister(). You can find the equivalent for OGR at OSGeo.OGR.Ogr.RegisterAll(). They look to be very similar except the autogenerated function has extra checks to not execute these if the drivers were already registered. The helper also adds some printer initialization.

Maybe it's a build order problem; that this code is sometimes, for some reason, generated after the build. This explains why Visual Studio sees it but not during build. I recall I've seen something similar before and that time this was the cause.

0

I'd like to see if there was any update on this issue. I am running into the same problem and am surprised that the editor can find the file but the compiler cannot. I am sure there is something silly going on but I am unable to figure it out.

In the meantime, my solution to the problem was to simply copy the contents of GdalConfiguration.cs into my own file and I renamed the class (and static constructor) to MyGdalConfiguration. Called this instead and everything seems to be working (so far). YMMV...

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.