首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SqlGeometry / DbGeometry在Azure角色上托管时是有效的异常

SqlGeometry / DbGeometry在Azure角色上托管时是有效的异常
EN

Stack Overflow用户
提问于 2013-07-31 17:48:29
回答 2查看 2K关注 0票数 2

我正在尝试创建一个DbGeometry类型的多边形。它在我的本地机器上工作很好,但是当我在Azure Web角色上托管我的网站时,返回语句出现了错误。

代码:

代码语言:javascript
复制
string polygon = “POLYGON ((-30.3637216 30.7124139,-30.3632216 30.7124139,-30.3632216 30.7129139,-30.3637216 30.7129139,-30.3637216 30.7124139))”;

return DbGeometry.FromText(polygon, 4326);

例外:

代码语言:javascript
复制
Exception has been thrown by the target of an invocation.


at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)

   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

   at System.Data.SqlClient.SqlSpatialServices.GeometryFromText(String geometryText)

   at Library.Modules.FindMyWay.SpatialFunctions.GetDefaultBox(Decimal latitude, Decimal longitude)

   at Library.Stop.ImportStops(String userName, IEnumerable`1 stops, Int32 companyId) Inner Exception:    at Microsoft.SqlServer.Types.GLNativeMethods.IsValid(GeoMarshalData g, Boolean& result)

   at Microsoft.SqlServer.Types.GLNativeMethods.IsValid(GeoData g)

   at Microsoft.SqlServer.Types.SqlGeometry.IsValidExpensive()

   at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid)

   at Microsoft.SqlServer.Types.SqlGeometry.Parse(SqlString s)

你知道为什么这个多边形无效吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-08-01 10:51:11

好的,通过将SqlGeometry转换为DbGeometry,我以一种迂回的方式修复了这个问题:

is there something like dbgeometry makevalid in .net 4.5

代码语言:javascript
复制
SqlGeometry geom = SqlGeometry.STPolyFromText(new SqlChars(new SqlString(polygon)), 4326);
                 return DbGeometry.FromBinary(geom.STAsBinary().Buffer);

此代码产生异常:

代码语言:javascript
复制
Unable to load DLL 'SqlServerSpatial.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

修复:

Unable to load DLL 'SqlServerSpatial.dll'

64位dll导致此异常:

代码语言:javascript
复制
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

因此,我不得不将32位dll添加到项目中,以便与Azure一起工作。

结果:现在很好,但是我仍然不知道为什么DbGeometry不工作在Azure上,也不知道为什么64位dll也不工作在Azure上。

票数 1
EN

Stack Overflow用户

发布于 2015-05-26 12:45:31

我也有同样的问题。我的修正是将以下Dll放在文件夹C:/windows/System32 32中:

SqlServerSpatial.dll SqlServerSpatial110.dll

实体框架根据以下来源使用这些dll:https://alastaira.wordpress.com/2011/08/19/spatial-applications-in-windows-azure-redux-including-denali/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17977391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档