【问题标题】:DbGeography does not work when published to a serverDbGeography 在发布到服务器时不起作用
【发布时间】:2021-04-10 22:50:51
【问题描述】:

以下代码在调试时在我的本地机器上运行,但在发布到服务器时抛出错误。

public IEnumerable<Restaurant> Nearby(double latitude, double longitude, double distance)
{
    var region = DbGeography.PointFromText(string.Format("POINT({1} {0})", latitude, longitude), 4326).Buffer(10000);
    return Find(x => SqlSpatialFunctions.Filter(x.Location, region) ?? false);
}

在像疯子一样搜索之后,我从nuget安装了Microsoft.SqlServer.Types。 (版本 14.0.1016.290)

在~/bin文件夹中添加了所需的dll(由上面的包提供)。

在 Global.asax.cs 中添加以下代码

SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));

但代码仍然抛出“500 Internal Server Error. An error has occurred”。

注意:这在我的本地机器上完美运行。

【问题讨论】:

    标签: asp.net sql-server asp.net-mvc dbgeography


    【解决方案1】:

    哇,终于answer 成功了。

    注意:我必须包含来自

    Microsoft.SqlServer.Types.dll

    ~/packages/Microsoft.SqlServer.Types.14.0.1016.290\lib\net40 在 ~/bin 文件夹中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-09
      • 2015-02-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多