首页 > 数据库技术 > 详细

应用SqlGeometry无法加载sqlserverspatial.dll

时间:2016-01-26 10:38:36      阅读:935      评论:0      收藏:0      [点我收藏+]

最近需要完成一个API,通过用户上传的经纬度判断用户的所在县市省,数据量相对不是很大所以把相关数据全部扔到了内存里知行,主要用到了SqlGeometry,

代码写完后运行本地没问题,扔到服务器上开始报异常“无法加载sqlserverspatial.dll”,一时蛋疼菊紧。难道还得装个sql server的服务吗。。。显然不用- -留下点笔记以备后用。。

Any application that uses Entity Framework’s spatial data type support to target SQL Server requires the ‘CLR Types for SQL Server’ to be available on the machine the application runs on. This also applies to applications that use SQL Server spatial data types directly, without using Entity Framework.(就是说想用SQL Server的功能一般得装个CLR Types for SQL Server)

When developing your application the CLR Types for SQL Server are usually installed system-wide, since they are included in Visual Studio. Issues arise when you try to deploy to a machine that does not have the CLR Types for SQL Server installed. Initially you will get the following InvalidOperationException.

Spatial types and functions are not available for this provider because the assembly ‘Microsoft.SqlServer.Types‘ version 10 or higher could not be found.

If you were to find and deploy the Microsoft.SqlServer.Types assembly you’ll then get the following DllNotFoundException.

Unable to load DLL ‘SqlServerSpatial110.dll‘: The specified module could not be found. (Exception from HRESULT: 0x8007007E) ()

(正常思路是引用Microsoft.SqlServer.Types.dll就以为OK了。。然而依然会有异常

解决方案:

安装 Microsoft.SqlServer.Types NuGet package

PM> Install-Package Microsoft.SqlServer.Types
然后项目下出现:
技术分享
看看readme就啥都解决了。。。
大致就是说想跑起来的话你可以提前加载SqlServerSpatial110.dll这样就不需要装System CLR Types for SQL Server了
然后这个分32位和64位的
然后如果是web可以在程序入口Globle,starup啥的加个 SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
如果是桌面应用啥的就在起始加个SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
 
最后觉得。。感觉.net的gis资源很丰富啊!

 

应用SqlGeometry无法加载sqlserverspatial.dll

原文:http://www.cnblogs.com/ylsforever/p/5159315.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!