注意问题:
1.GDAL 使用官网生成好的dll,必须把Bin目录下的dll一并加到执行目录下去,否则会出错。
2. 用环境变量设置引用路径可以避免一大堆dll放一起。代码如下:
///
///Function to determine which platform we're on///
private static stringGetPlatform()
{return IntPtr.Size == 4 ? "x86" : "x64";
}///
///Construction of Gdal/Ogr///
public static voidGdal_Configuration()
{var executingAssemblyFile = newUri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;var executingDirectory =Path.GetDirectoryName(executingAssemblyFile);if (string.IsNullOrEmpty(executingDirectory))throw new InvalidOperationException("cannot get executing directory");var gdalPath = Path.Combine(executingDirectory, "gdal");var nativePath =Path.Combine(gdalPath, GetPlatform());//Prepend native path to environment path, to ensure the//right libs are being used.