When using the C # version of gdal for development, the compilation is normal. When it is started, the system will prompt "osgeo. gdal. gdalpinvoke" type Initial Value Setting item to cause an exception. "
For this problem, the main cause is that the DLL is not found. When using it, we should not only copy the eight DLL files of C # To the directory where the EXE is located, we also need to copy gdal19.dll and its dependent DLL. Many people think that if there are eight C # versions of DLL, it will be OK. In fact, it is not correct, in C #, the 8 DLL files only export the C # interface and call the C ++ version gdal library.
The same is true for python. Copy gdal19.dll and its dependent DLL to the python installation directory.
-------- Gorgeous split line, add ------------------ on February 14 ----------------
When using the C # version, you must pay attention to the compiler and version used for compiling gdal, such as the 32-bit DLL compiled by vs2008 for the gdal you downloaded, when using it in C #, you must first install the C ++ Runtime Library of visual studio2008. For details, go to Microsoft's official search (note that there are also a lot of vs versions, there are SP1 versions, and versions that have not been sp, And the runtime libraries are different ). After completing these steps, we recommend that you use the exe tool of gdal to test it. Double-click one of them. If you can pop up the help information, OK. If not, continue to find the corresponding C ++ Runtime Library.
The above only shows that gdal can work normally in your system. The following describes how to modify anycpu In the Configuration Manager when calling C #. If gdal is 32-bit, here we need to create an x86 instance. If it is 64-bit and an x64 instance is created, do not make sure it is corresponding. Otherwise, some exceptions will occur, as shown in the following figure.