Microsoft.SqlServer.Types.SqlGeography GAC 中的 DLL
Microsoft.SqlServer.Types.SqlGeography DLL's in GAC
我安装了 Nuget Microsoft.SqlServer.Types
并且有一个 DLL 版本问题。
我已阅读自述文件并在 global.asax (Webform web app)
中添加了行
protected void Application_Start(object sender, EventArgs e)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
}
An exception of type 'System.InvalidCastException' occurred in System.Data.DataSetExtensions.dll but was not handled in user code
Additional information: [A]Microsoft.SqlServer.Types.SqlGeography kan niet worden geconverteerd naar [B]Microsoft.SqlServer.Types.SqlGeography. Type A is afkomstig uit Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 in de context Default op locatie C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll. Type B is afkomstig uit Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 in de context Default op locatie C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll.
这条线失败了:
var bla = myDataTable.AsEnumerable().Select(x => new
{
Loc = x.Field<Microsoft.SqlServer.Types.SqlGeography>("theLocation") // breaks
}).ToList();
theLocation 在我的 Sql Server 2008 中属于地理数据类型,因此很遗憾没有 2016 FOR JSON PATH
选项。
ps。一些背景信息:我安装了 nuget GeoJSON.Net 和 GeoJSON.Net.Contrib.MsSqlSpatial 来获取地理数据类型行作为 geojson。或者我应该在我的 sql 中添加 .tostring 并将其解析为 geojson 点?
从Arne Klein (8 May 2014 5:08 AM)
这里找到
The SqlClient loads by default the Microsoft.SqlServer.Types Version 10.0 and with SQL Server 2012 V. 11 is needed. This problem can be solved by adding the following to the web.config.
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
It would be great if the Nuget package could be updated to automatically add this to the web.config.
我同意 Arne 的观点,添加该选项会很棒。
我安装了 Nuget Microsoft.SqlServer.Types
并且有一个 DLL 版本问题。
我已阅读自述文件并在 global.asax (Webform web app)
protected void Application_Start(object sender, EventArgs e)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
}
An exception of type 'System.InvalidCastException' occurred in System.Data.DataSetExtensions.dll but was not handled in user code
Additional information: [A]Microsoft.SqlServer.Types.SqlGeography kan niet worden geconverteerd naar [B]Microsoft.SqlServer.Types.SqlGeography. Type A is afkomstig uit Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 in de context Default op locatie C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll. Type B is afkomstig uit Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 in de context Default op locatie C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll.
这条线失败了:
var bla = myDataTable.AsEnumerable().Select(x => new
{
Loc = x.Field<Microsoft.SqlServer.Types.SqlGeography>("theLocation") // breaks
}).ToList();
theLocation 在我的 Sql Server 2008 中属于地理数据类型,因此很遗憾没有 2016 FOR JSON PATH
选项。
ps。一些背景信息:我安装了 nuget GeoJSON.Net 和 GeoJSON.Net.Contrib.MsSqlSpatial 来获取地理数据类型行作为 geojson。或者我应该在我的 sql 中添加 .tostring 并将其解析为 geojson 点?
从Arne Klein (8 May 2014 5:08 AM)
这里找到The SqlClient loads by default the Microsoft.SqlServer.Types Version 10.0 and with SQL Server 2012 V. 11 is needed. This problem can be solved by adding the following to the web.config.
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
It would be great if the Nuget package could be updated to automatically add this to the web.config.
我同意 Arne 的观点,添加该选项会很棒。