C# 使用地理空间操作时在生产上出现BadImageFormatException
我正在从事一个windows服务项目,该项目使用EF和SQLServer的地理空间功能。我正在生产中使用C# 使用地理空间操作时在生产上出现BadImageFormatException,c#,sql-server,geospatial,C#,Sql Server,Geospatial,我正在从事一个windows服务项目,该项目使用EF和SQLServer的地理空间功能。我正在生产中使用SQL Server 2014。我在服务器上安装了至少2-3次SQLSysClrTypes.msi,并且NuGet正在管理我的Microsoft.SqlServer.Types包。我想这不会是x86/x64的问题,因为我有一个SqlServerTypes文件夹,其中,x86以及x64DLL驻留在各自的文件夹中(即x86和x64) 我面临的具体例外情况如下: Inner Exception: S
SQL Server 2014
。我在服务器上安装了至少2-3次SQLSysClrTypes.msi
,并且NuGet正在管理我的Microsoft.SqlServer.Types包。我想这不会是x86/x64的问题,因为我有一个SqlServerTypes文件夹,其中,x86以及x64DLL驻留在各自的文件夹中(即x86和x64)
我面临的具体例外情况如下:
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)
有人能告诉我为什么我会面临这个例外吗
这是Microsoft在解决此错误方面提供的最佳解决方案:
当您试图在x64进程中加载x86 DLL时,会出现该异常,反之亦然。有一个32位和64位的Microsoft.SqlServer.Types DLL,您需要正确的。不记得最后一项,但您必须进行测试,但是一些本机DLL甚至不能与任何CPU一起工作,您必须特别匹配