当前位置:   article > 正文

gdal依赖dll_请问.NET Core平台下调用GDAL库相关dll的问题

gdal202.dll 如何添加到.netcore 项目中,并且正常使用gdal类

GDAL本身是C++编写的,通过DllImport / PINVOKE的方式封装为C#可以调用的类:

1)GdalPINVOKE中引入gdal_wrap.dll:

[DllImport("gdal_wrap", EntryPoint="CSharp_SetConfigOption")]

public static extern void SetConfigOption(string jarg1, string jarg2);

2) Gdal.cs中调用GdalPINVOKE

public static void SetConfigOption(string pszKey, string pszValue) {

GdalPINVOKE.SetConfigOption(pszKey, pszValue);

if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();

}

3)实际使用中调用Gdal:

Environment.SetEnvironmentVariable("GEOTIFF_CSV", gdalData);

Gdal.SetConfigOption("GEOTIFF_CSV", gdalData);

现在,在windows 操作系统中,以上的过程可以正常调用;但是在Linux环境下调用的时候,提示无法加载gdal_wrap.dll,缺少dll或它的依赖项:

System.TypeInitializationException: The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'gdal_wrap': The specified module or one of its dependencies could not be found.

(Exception from HRESULT: 0x8007007E)

我尝试把可能依赖的dll都放到运行目录下,仍然无法正常调用。

请问,有没有高手碰到过类似的问题?

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号