Gdal C # "osgeo. gdal. gdalpinvoke" type Initial Value Setting raises an exception Solution

Source: Internet
Author: User

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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.