2016-08-16 42 views
0

我在一個Windows服務項目,它採用EF的地理空間功能和SQLServer的工作。我在生產中使用SQL Server 2014。我已經在服務器上安裝了SQLSysClrTypes.msi至少2-3次,而且NuGet正在管理我的Microsoft.SqlServer.Types包。我猜這不會是x86/x64的問題,因爲我有一個SqlServerTypes文件夾,其中,x86以及x64 DLL駐留在它們各自的文件夾(即x86和x64)中。BadImageFormatException生產,同時利用地理空間操作的

我對着詳細的異常情況如下:

Inner Exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) 
    at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIntersects(GeoMarshalData g1, GeoMarshalData g2, Double eccentricity, Boolean& result) 
    at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIntersects(GeoData g1, GeoData g2, Double eccentricity) 
    at Microsoft.SqlServer.Types.SqlGeography.STIntersects(SqlGeography other) 
    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.Intersects(DbGeography geographyValue, DbGeography otherGeography) 
    at System.Data.Entity.Spatial.DbGeography.Intersects(DbGeography other) 

任何人能告訴我爲什麼我可能會面臨這樣的例外?

這是最好的微軟所提供的有關解決此錯誤: https://msdn.microsoft.com/en-us/library/k7137bfe.aspx

回答

0

你得到當你試圖在X64的過程,反之亦然加載DLL的x86該異常。有一個32位和64位Microsoft.SqlServer.Types DLL,你需要正確的。不記得這最後一項,但你必須測試,但一些本地DLL甚至不會與AnyCPU一起工作,你必須特別匹配。