【问题标题】:Microsoft.SqlServer.Types.SqlGeography DLL's in GACGAC 中的 Microsoft.SqlServer.Types.SqlGeography DLL
【发布时间】:2016-08-10 07:35:38
【问题描述】:

我安装了 Nuget Microsoft.SqlServer.Types 并且有一个版本的 DLL 问题。 我已阅读自述文件并在 global.asax (Webform web app) 中添加了这一行

protected void Application_Start(object sender, EventArgs e)
{
    SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
}

System.Data.DataSetExtensions.dll 中出现“System.InvalidCastException”类型的异常,但未在用户代码中处理

附加信息:[A]Microsoft.SqlServer.Types.SqlGeography 看一下 geconverteerd naar [B]Microsoft.SqlServer.Types.SqlGeography。类型 A 是 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\10.0.0.0__89845dcd8080cc91\ Microsoft.SqlServer.Types.dll。类型 B 是 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\11.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 中属于数据类型 geography,因此很遗憾我没有 2016 FOR JSON PATH 选项。

ps。一些背景信息:我安装了 nuget GeoJSON.Net 和 GeoJSON.Net.Contrib.MsSqlSpatial 来获取 geojson 的地理数据类型行。还是我应该在我的 sql 中添加 .tostring 并将其解析为 geojson 点?

【问题讨论】:

    标签: c# dll gac sqlgeography


    【解决方案1】:

    Arne Klein (8 May 2014 5:08 AM)找到这里

    SqlClient 默认加载 Microsoft.SqlServer.Types 版本 10.0 和 SQL Server 2012 V. 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,那就太好了。

    我同意 Arne 的观点,这个补充会很棒。

    【讨论】:

    • 在我的情况下是&lt;bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" /&gt;
    猜你喜欢
    • 1970-01-01
    • 2017-05-29
    • 1970-01-01
    • 1970-01-01
    • 2011-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多