【问题标题】:Microsoft.SqlServer.Types incompatible with .NET StandardMicrosoft.SqlServer.Types 与 .NET 标准不兼容
【发布时间】:2019-06-24 04:18:37
【问题描述】:

我正在尝试将我们所有的 C# 类库从 .NET Framework 转换为 .NET Standard 项目,因为我们开始利用 .NET Core,因此需要 .NET Core 和 .NET Framework 应用程序都可以使用这些类库(后者将在未来几个月内移植到 Core。)

我在转换数据访问层代码时遇到问题,因为我们广泛利用 Microsoft.SqlServer.Types,而official NuGet package 不支持 .NET Standard。我尝试了unofficial NuGet package by dotmorten,但它缺少很多功能。下面是我们需要的所有缺失的列表(放在一起构建代码......)

public static class SqlMockExtensions
{
    public static SqlBytes STAsBinary(this SqlGeography geography) => throw new NotImplementedException();

    public static SqlGeography MakeValid(this SqlGeography geography) => throw new NotImplementedException();

    public static int STDimension(this SqlGeography geography) => throw new NotImplementedException();

    public static bool STIsValid(this SqlGeography geography) => throw new NotImplementedException();

    public static Nullable<double> EnvelopeAngle(this SqlGeography geography) => throw new NotImplementedException();

    public static SqlGeography ReorientObject(this SqlGeography geography) => throw new NotImplementedException();

    public static SqlGeography BufferWithTolerance(this SqlGeography geography, double arg1, int arg2, bool arg3) => throw new NotImplementedException();

    public static SqlGeography Reduce(this SqlGeography geography, double tolerance) => throw new NotImplementedException();

    public static SqlGeography EnvelopeCenter(this SqlGeography geography) => throw new NotImplementedException();

    public static double STDistance(this SqlGeography geography, SqlGeography point2) => throw new NotImplementedException();

    public static SqlBytes STAsBinary(this SqlGeometry geometry) => throw new NotImplementedException();
}

当我 search SO 其他人尝试将 Microsoft.SqlServer.Types 集成到他们的 .NET Core 和 Standard 项目中时,我看到提到包含官方 NuGet 包然后执行以下操作:

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

但是,当您尝试将不符合 .NET Standard 的 NuGet 包添加到 .NET Standard 项目时,它会出错,所以我不清楚这是如何解决的。

这似乎是一个非常普遍的问题,必须有很多开发人员利用 Microsoft.SqlServer.Types 进行 SqlGeography、SqlGeometry 等......并且正在移植到 .NET Standard。那么你们是如何做到这一点的呢?

【问题讨论】:

  • 同样的问题...不确定您是否关注此github.com/dotnet/corefx/issues/31775
  • 你是怎么解决这个问题的?由于这个问题,我无法将我的一些应用程序迁移到 .NET Standard
  • @RobL 我最终只是直接引用了 DLL(浏览并将它们添加为普通引用),而不是使用 nuget 包。这显然不适用于非 Windows 平台上的 .NET Standard。

标签: c# sql-server .net-standard sqlgeography sqlgeometry


【解决方案1】:

对于它的价值,我们没有找到答案。

我们最终迁移到了 EF Core。

【讨论】:

    猜你喜欢
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    相关资源
    最近更新 更多