Exception while using GDAL in C#

后端 未结 8 526
囚心锁ツ
囚心锁ツ 2020-12-11 02:35

I started to use gdal_csharp dll in my application and read a geotiff file. but it says:

The type initializer for \'OSGeo.GDAL.GdalPINVOKE\'         


        
8条回答
  •  佛祖请我去吃肉
    2020-12-11 02:47

    I know it's an old question, but I believe my answer might help someone.

    I was able to successfully compile and run examples using c# gdal by doing the following:

    1. Downloading GDAL sdk from http://www.gisinternals.com/ (64 bit in my case)
    2. Executing the SDKShell.bat script to set the system environment paths, etc.
    3. Creating a project in Visual Studio. And referencing all .net dlls (the ones that names end with _csharp.dll), located in \bin\gdal\csharp\ inside downloaded SDK
    4. Setting platform target in Visual Studio project settings to x64 to get rid og bad image format exceptions. The last step wouldn't be necessary if I'd choosse 32bit version of SDK to work with.

    I did not install fwtools at all. It seems like the last build of fw_tools is relatively old, and sdk is still maintained.

提交回复
热议问题