我安装了Nuget Microsoft.SqlServer.Types
并发布了DLL问题。我已经阅读了自述文件,并在global.asax (Webform应用程序)中添加了行。
protected void Application_Start(object sender, EventArgs e)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
}
“System.InvalidCastException”类型的异常发生在System.Data.DataSetExtensions.dll中,但未在用户代码中处理 更多信息: AMicrosoft.SqlServer.Types.SqlGeography Additional geconverteerd naar BMicrosoft.SqlServer.Types.SqlGeography。类型A是afkomstig uit Microsoft.SqlServer.Types、Version=10.0.0.0、Culture=neutral、PublicKeyToken=89845dcd8080cc91在de上下文中默认的op定位B类型是afkomstig uit Microsoft.SqlServer.Types,Version=11.0.0.0,Culture=neutral,PublicKeyToken=89845dcd8080cc91在de上下文中默认的op定位
它在这一行失败了:
var bla = myDataTable.AsEnumerable().Select(x => new
{
Loc = x.Field<Microsoft.SqlServer.Types.SqlGeography>("theLocation") // breaks
}).ToList();
theLocation是我的Server 2008中的数据类型地理类型,所以我很不幸没有2016 FOR JSON PATH
选项。
ps。一些背景信息:我安装了nuget GeoJSON.Net和GeoJSON.Net.Contrib.MsSqlSpatial以获取地理数据类型行为geojson。还是应该在sql中添加.tostring并将其解析为geojson点?
发布于 2016-04-18 06:07:45
在这里发现的Arne Klein (2014年5月8日上午5:08 )
默认情况下,SqlClient加载Microsoft.SqlServer.Types版本10.0,并使用SQLServer2012V.11加载。这个问题可以通过向web.config中添加以下内容来解决。
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
如果Nuget包可以被更新以自动将其添加到web.config中,那就太好了。
我同意阿恩的意见,那样的话就太好了。
https://stackoverflow.com/questions/36696104
复制相似问题