Geographic Information Systems Asked by Chau on February 14, 2021
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
objDebugNuGet15f0ca2b5ecbe407152208e918cf2c4389b630a2GDAL2.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?
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.
Answered by Jonas on February 14, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP