Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load DLL 'SqlServerSpatial.dll'

I have a .NET MVC web application referencing System.Data.Spatial so I can use the DbGeography datatype on a property for some geolocation stuff. I'm using Visual Studio 2012 with .NET 4.5 and do not have a full installation of SQL Server on my development machine (only localdb).

The app works great until I push it to Azure. As soon as my app hits my DbGeography property, it throws this error:

Unable to load DLL 'SqlServerSpatial.dll': The specified module could not be found.

Has anyone else encountered this issue?

like image 421
ryanw51 Avatar asked Jun 01 '13 01:06

ryanw51


3 Answers

SqlServerSpatial.dll is unmanaged code. You have to install the correct version (64bit) on the server. Add the DLL to your project. Set the properties of SqlServerSpatial110.dll to “Copy to Output directory = Copy always”

You find detailed Information here

like image 153
slfan Avatar answered Sep 27 '22 06:09

slfan


SQL 2012 installs this dll too, SQL 2014 don't! You have to install the Microsoft System CLR Types for SQL Server 2008 R2 on the machine.

  1. http://www.microsoft.com/en-us/download/details.aspx?id=26728
  2. Click Download
  3. Check off one of these depending on your processor architecture:

    • 1033\x64\SQLSysClrTypes.msi
    • 1033\x86\SQLSysClrTypes.msi
    • 1033\IA64\SQLSysClrTypes.msi
  4. Click Next

Edit

as Ian Grainger's comment, you have to install the correct version based on your IIS. apparently IIS Express runs in 32bit mode by default.

like image 2
Mahmood Dehghan Avatar answered Sep 27 '22 06:09

Mahmood Dehghan


<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
  <assemblyIdentity name="Microsoft.SqlServer.Types" 
  publicKeyToken="89845dcd8080cc91" culture="neutral" />
  <bindingRedirect oldVersion="10.0.0.0" newVersion="12.0.0.0" />
  </dependentAssembly>
  </assemblyBinding>
</runtime>
like image 2
David Chen Avatar answered Sep 27 '22 06:09

David Chen