.net 无法加载 DLL 'SqlServerSpatial.dll'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16868326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to load DLL 'SqlServerSpatial.dll'
提问by ryanw51
I have a .NET MVC web application referencing System.Data.Spatialso I can use the DbGeographydatatype 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).
我有一个 .NET MVC Web 应用程序引用,System.Data.Spatial因此我可以将DbGeography属性上的数据类型用于某些地理定位。我正在使用带有 .NET 4.5 的 Visual Studio 2012,并且在我的开发机器上没有完整安装 SQL Server(只有 localdb)。
The app works great until I push it to Azure. As soon as my app hits my DbGeographyproperty, it throws this error:
该应用程序运行良好,直到我将其推送到 Azure。一旦我的应用程序命中我的DbGeography属性,它就会抛出此错误:
Unable to load DLL 'SqlServerSpatial.dll': The specified module could not be found.
无法加载 DLL 'SqlServerSpatial.dll':找不到指定的模块。
Has anyone else encountered this issue?
有没有其他人遇到过这个问题?
采纳答案by slfan
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”
SqlServerSpatial.dll 是非托管代码。您必须在服务器上安装正确的版本(64 位)。将 DLL 添加到您的项目中。将SqlServerSpatial110.dll的属性设置为“复制到输出目录=始终复制”
You find detailed Information here
您可以在此处找到详细信息
回答by Mahmoodvcs
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.
SQL 2012 也安装了这个 dll,SQL 2014 没有!您必须在机器上安装 Microsoft System CLR Types for SQL Server 2008 R2。
- http://www.microsoft.com/en-us/download/details.aspx?id=26728
- Click Download
Check off one of thesedepending on your processor architecture:
- 1033\x64\SQLSysClrTypes.msi
- 1033\x86\SQLSysClrTypes.msi
- 1033\IA64\SQLSysClrTypes.msi
Click Next
- http://www.microsoft.com/en-us/download/details.aspx?id=26728
- 点击下载
根据您的处理器架构检查其中之一:
- 1033\x64\SQLSysClrTypes.msi
- 1033\x86\SQLSysClrTypes.msi
- 1033\IA64\SQLSysClrTypes.msi
单击下一步
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.
作为Ian Grainger评论,您必须根据您的 IIS 安装正确的版本。显然 IIS Express 默认以 32 位模式运行。
回答by David Chen
<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>
回答by pflous
I ran into this problem and was truly missing the SqlServerSpatial110.dll
我遇到了这个问题,确实缺少 SqlServerSpatial110.dll
I ended up following the instructions here:
我最终按照此处的说明进行操作:
http://dllyes.com/sqlserverspatial110-dll/
http://dllyes.com/sqlserverspatial110-dll/
Basically you need to get your hands on that .dll and then
基本上你需要拿到那个 .dll 然后
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.
如果您运行的是 32 位 Windows,请将 SqlServerSpatial110.dll 放在 \Windows\System32(通常位于磁盘 C)中。如果您运行的是 64 位 Windows,请另外将文件放在 \Windows\SysWOW64 中。
回答by Andrew Mara
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
显然,该项目想要使用 x86 SqlServerSpatial.dll 所以我在工具>选项>WebProjects>使用 64 位 IIS 中将 IIS Express Build 更改为 x64 这是屏幕
There is no need of adding new nuget packages, just install the SQLSysClrTypes from microsoft page : http://go.microsoft.com/fwlink/?LinkID=188391&clcid=0x409and it should be fine ;)
不需要添加新的 nuget 包,只需从微软页面安装 SQLSysClrTypes:http: //go.microsoft.com/fwlink/?LinkID=188391&clcid=0x409 应该没问题;)
Hope that it helps someone!
希望它可以帮助某人!
回答by John
I had the same issue in godaddy VPS with windows server 2012 r2
I Resolved it by Updating my EF5 to EF6
我通过将 EF5 更新为 EF6 解决了这个问题
in package manager console run to EF5 to EF lalest
在包管理器控制台中运行到 EF5 到 EF lalest
Install-Package EntityFramework
回答by Hossein Narimani Rad
SqlGeometryandSqlGeographytypes can be used in VS projects (e.g. C#) by referencing theMicrosoft.SqlServer.Types.dll.Microsoft.SqlServer.Types.dllis a managed library and has some unmanaged library as prerequisites and they are likeSqlServerSpatialXXX.dllandmsvcrXXX.dll- Since Sql Server 2008, different versions of
Microsoft.SqlServer.Types.dllare available, however, I don't see any functionality change from 2012 on.
SqlGeometry和SqlGeography类型可以通过引用Microsoft.SqlServer.Types.dll.Microsoft.SqlServer.Types.dll是一个托管库,并且有一些非托管库作为先决条件,它们就像SqlServerSpatialXXX.dll和msvcrXXX.dll- 从 Sql Server 2008 开始,可以使用不同的版本
Microsoft.SqlServer.Types.dll,但是,从 2012 年开始,我没有看到任何功能更改。
For a detailed solution you may want to see my answeron another similar post.
对于详细的解决方案,您可能希望在另一篇类似的帖子中看到我的回答。

