Watch out for gotcha with missing VC++ runtime dlls when deploying .NET applications that leverage the new SQL Server Spatial Types libraries.

In my previous blog post I discussed the ability to leverage the SQL Server type library in your own .NET applications.  The article showed how to create a simple console application that calculates some areas for different shapes and how to create these shapes either from a text representation like WKT or “by hand” using the builder classes in the spatial library.

I did not spend much time on discussing the details of deploying your spatially-enabled .NET application to other machines (client or server) since I expected it to be like any other .NET application: Just copy the EXE along with any dependent assemblies to the target machine and run, of if motivated, create a simple setup project, or possibly use Publish to create a click-once installer.

The best laid plans of…

It turns out that deployment of a spatially-enabled .NET application onto a “clean” target machine has a potential *gotcha*.

Taking the example of the simple .NET console application from the previous blog, there are several expected pre-requisites necessary on the target machine in order for the application to run successfully:

  • .NET Framework: that one is pretty obvious given my console application was a .NET application.
  • SQL Server Types: Running this installer will install and register the SQL Types assembly in the GAC.  Alternatively you could place the SQL types assembly as a side-by-side assembly to your application.

It turns out that you will also need to make sure the Visual C++ 2008 C runtime libraries are also installed on that target machine.

The spatial data types make use of both managed code (.NET) and native code to speed up spatial calculations and as a result the spatial types make calls to some C runtime library functions. 

If these C runtime libraries are not installed on your target machine you will get the following exception when you run your application:

Unable to load DLL 'SqlServerSpatial.dll': This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

You can find the 32bit version of the VC++ redistributables here and the 64bit version here.  Run the appropriate version for your target environment and that should resolve the problem. 

Alternatively build an installer for your application that installs the C runtime libraries as part of the installation of your application (note that I did not try this, so let me know if you run into any problems).

You can read more about this scenario on the Microsoft support site here.

Happy coding.


Comments (0)

Skip to main content