I am working on a windows service project, which uses geospatial features of EF and SQLServer. I am using SQL Server 2014
in production. I have installed SQLSysClrTypes.msi
at least 2-3 times on server and also NuGet is managing my Microsoft.SqlServer.Types package. I guess it wouldn't be x86 / x64 problem because I have a SqlServerTypes folder, in which, x86 as well as x64 DLLs reside in their separate folders (namely x86 and x64).
The detailed exception I am facing is as follows:
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)
Can anybody please tell me why I might be facing this exception?
That's the best Microsoft has to offer regarding troubleshooting this error: https://msdn.microsoft.com/en-us/library/k7137bfe.aspx
You get that exception when you are trying to load a x86 DLL in a x64 process or vice versa. There is a 32-bit and 64-bit Microsoft.SqlServer.Types DLL and you need the right one. Don't remember this one last item, but you'll have to test, but some native DLLs won't even work with AnyCPU, you specifically have to match.
User contributions licensed under CC BY-SA 3.0