4

现在花了几天非常令人沮丧的日子,试图让空间类型 DbGeography 在 Windows Azure 上工作。我有一个带有 Webrole 的 Windows Azure 项目,我在其中使用 DbGeography.Distance() 方法来计算距离。在我的本地计算机上工作就像一个魅力,但一旦发布到 Azure,我得到了例外:

Search spa  failed message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticDistance(GeoMarshalData g1, GeoMarshalData g2, EllipsoidParameters ellipsoidParameters, Double& result)
   at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticDistance(GeoData g1, GeoData g2, EllipsoidParameters ellipsoidParameters)
   at Microsoft.SqlServer.Types.SqlGeography.STDistance(SqlGeography other)
   --- End of inner exception stack trace ---
   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.Entity.SqlServer.SqlSpatialServices.Distance(DbGeography geographyValue, DbGeography otherGeography)
   at System.Data.Entity.Spatial.DbGeography.Distance(DbGeography other)
   at DataAccess.Util.DistanceHelper.GetDistanceDictionary(DbGeography spaLocation)
   at MvcWebRole.Controllers.SpaController.SearchSpa(String searchString)

我已关注博客文章http://alastaira.wordpress.com/2011/08/19/spatial-applications-in-windows-azure-redux-include-denali/添加对 Sql.Server.Types 和 SqlServerSpatial.dll 的引用、msvcp100.dll 和 msvcr100.dll。Thist 实际上与 EF5 和一个 Azure 网站项目一起使用,但现在当我升级到 EF6 和一个云服务项目时不是这样:(

4

1 回答 1

1

System.BadImageFormatException 意味着您正在部署错误版本的本机程序集(x86 与 x64)。

我们发布了一个 NuGet 包以简化此操作 - 请查看此帖子了解详细信息http://blogs.msdn.com/b/adonet/archive/2013/12/09/microsoft-sqlserver-types-nuget-package-空间-on-azure.aspx

于 2013-12-09T17:53:54.677 回答