The short story
You can get a fully working GDAL in .NET (x64) from here: https://bitbucket.org/bjartn/gdalgonewild
For 32 bits windows you would need to do what I have done, but starting with the 32 bits C assemblies.
The somewhat longer story
Gdal is a translator library for raster geospatial data formats. It supports reading and writing many raster formats. One of them is GeoTiff, which is why I needed to use GDAL.
GDAL is written in C, but has bindings to many other languages thru SWIG. SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
For the .NET crowd this means that there are some .NET dll’s that talks to the GDAL C assemblies thru P/Invoke.
The good news is that as a .NET developer you don’t need to compile the entire GDAL library with the bindings yourself. The bad news is that it is not straight forward to get it running in .NET (until now).
There are some different places you can get the assemblies needed. One of them is thru installing FWTools, another is by downloading from a build server http://vbkto.dyndns.org/sdk/ which is what I did.
Both these builds include many files you don’t need. What you *do need* is the dll’s and some data files for proj.4 and GDAL.
Setting up the environment the hard way
You also need to set up your environment variables so that GDAL knows where to look for the plugins, the data files and so on. The following environment variables need to be set correctly: PATH, GDAL_DATA,GDAL_DRIVER_PATH and PROJ_LIB.
If you install FWTools the environment will be set up by running the “C:\Program Files (x86)\FWTools2.4.7\bin\setfwenv.bat” in a command window. If you use the http://vbkto.dyndns.org/sdk/ build you can set up the environment using the “SDKShell.bat“ file.
Setting up the environment the easy way
We don’t want to set up the environment on every PC we are installing our software on. If we want to have an xcopy deployment of our .NET application we cannot rely on somebody manually setting the environment variables.
I have created a self contained Visual Studio project that runs GDAL without any external dependencies like the environment variables. You can download it at https://bitbucket.org/bjartn/gdalgonewild (x64 only). I created this project by picking and choosing the required DLLs and data files from a x64 build of GDAL found at http://vbkto.dyndns.org/sdk/.
I have created a class called GdalEnvironment that is responsible for setting up the GDAL environment. In addition I have added a “pre-build event” that copies all the required C and .NET assemblies into the bin directory when the application is compiled. This removes the need for setting up the PATH environment variable.
One little strange thing I noticed was that I was not able to set up the GDAL_DATA environment variable programmatically. So instead I used Gdal.SetConfigOption which overrides the environment variable.
Well. That’s all I can think of right now.