When using gdal under development C #, the compile-time is correct.
In the execution
Gdal.allregister ();
An exception occurred: the type initializer for OSGeo.GDAL.GdalPINVOKE "throws an error.
Solution:
Compile correctly, indicating that the Gdal main eight dynamic library DLLs have been added correctly.
GDAL_CSHARP.DLL,GDAL_WRAP.DLL,GDALCONST_CSHARP,GDALCONST_WRAP.DLL,OGR_CSHARP.DLL,OGR_WRAP.DLL,OSR_, respectively. Csharp.dll,osr_wrap.dll.
The _csharp.dll with tail is the file that the C # project needs to reference, and the band _wrap.dll needs to be placed directly in the execution directory.
The reason for the compilation error is that some other DLLs are missing.
GDAL C # DLL Download:
http://www.gisinternals.com/sdk/
On the URL above, click Stable Releases
You can click into the appropriate interface according to the version you are using. For example, the use of Win32.
Click to download,release-1800-gdal-1-11-4-mapserver-6-4-3.zip
After unpacking, open the Bin folder, there are n DLLs, copy these DLLs to the execution directory of the project (these DLLs also include the above eight DLLs, recommended replacement). Copy only the DLL for the Bin folder, not the other folders.
In addition, you can download Release-1800-gdal-1-11-4-mapserver-6-4-3-src.zip, which has the relevant source code, to conduct a deeper study.
GDAL Exceptions in C # development