SQL Server Unable to load DLL 'SqlServerSpatial.dll'

5lwkijsr  于 11个月前  发布在  其他
关注(0)|答案(9)|浏览(94)

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?

xienkqul

xienkqul1#

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

ubby3x7f

ubby3x7f2#

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
  • Check off one of these depending on your processor architecture:

  • 1033\x64\SQLSysClrTypes.msi

  • 1033\x86\SQLSysClrTypes.msi

  • 1033\IA64\SQLSysClrTypes.msi

  • 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.

6rvt4ljy

6rvt4ljy3#

<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>
4ioopgfo

4ioopgfo4#

I ran into this problem and was truly missing the SqlServerSpatial110.dll

I ended up following the instructions here:

http://dllyes.com/sqlserverspatial110-dll/

Basically you need to get your hands on that .dll and then
Place SqlServerSpatial110.dll in \Windows\System32 (usually located at disk C) if you’re running 32 bit Windows. If you’are running 64 bit Windows, additionally place file in \Windows\SysWOW64.

laximzn5

laximzn55#

I was struggling with it for a quite some time, i installed required files, but it still wasn't working.

Apparently, the project wanted to use x86 SqlServerSpatial.dll So i changed the IIS Express Build to x64 in Tools>Options>WebProjects>Use the 64 bit IIS Here is the screen

There is no need of adding new nuget packages, just install the SQLSysClrTypes from microsoft page : http://go.microsoft.com/fwlink/?LinkID=188391&clcid=0x409 and it should be fine ;)

Hope that it helps someone!

yhived7q

yhived7q6#

Make sure that your dlls(such as "sqlserverspatial110.dll" , "sqlserverspatial120.dll" , ..) be in this path "C:\Windows\SysWOW64";

vcudknz3

vcudknz37#

If the files are referenced in the project correctly and added to source control and the issue is still occurring, try installing the Microsoft System CLR Types for SQL Server on the machine it's failing on.

-Install the version matching the SqlServerTypes referenced in the project.

-Install either the 64 bit or 32 bit of SQLSysClrTypes.msi matching what the project is or 'msbuild' platform the compile script is using. This doesn't require the full version of SQL Server to be installed on the machine.

Version | Assembly
2005    | 9.0.0.0
2008    | 10.0.0.0
2008 R2 | 10.0.0.0
2012    | 11.0.0.0
2014    | 12.0.0.0
2016    | 13.0.0.0
2017    | 14.0.0.0
2019    | 15.0.0.0
2022    | 16.0.0.0
vof42yt1

vof42yt18#

  • SqlGeometry and SqlGeography types can be used in VS projects (e.g. C#) by referencing the Microsoft.SqlServer.Types.dll .
  • Microsoft.SqlServer.Types.dll is a managed library and has some unmanaged library as prerequisites and they are like SqlServerSpatialXXX.dll and msvcrXXX.dll
  • Since Sql Server 2008, different versions of Microsoft.SqlServer.Types.dll are available, however, I don't see any functionality change from 2012 on.

For a detailed solution you may want to see my answer on another similar post.

7hiiyaii

7hiiyaii9#

I had the same issue in godaddy VPS with windows server 2012 r2

I Resolved it by Updating my EF5 to EF6

in package manager console run to EF5 to EF lalest

Install-Package EntityFramework

相关问题