爲了讓空間類型DbGeography能夠在Windows Azure上工作,花了幾天非常沮喪的日子。我有一個使用DbGeography.Distance()方法計算距離的Webrole的Windows Azure項目。工程利卡魅力我的本地計算機上,但一旦發佈到Azure中我得到異常:Windows 6上的EF 6和空間類型DbGeography
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-including-denali/將參考Sql.Server.Types和SqlServerSpatial.dll,msvcp100.dll和msvcr100 .dll文件。 Thist實際上與EF5和一個Azure網站項目合作,但現在當我升級到EF6和雲服務項目時:
你找到一個解決方案,這一點,我已經得到了同樣的問題... –