zoukankan      html  css  js  c++  java
  • 应用SqlGeometry无法加载sqlserverspatial.dll

    最近需要完成一个API,通过用户上传的经纬度判断用户的所在县市省,数据量相对不是很大所以把相关数据全部扔到了内存里知行,主要用到了SqlGeometry,

    代码写完后运行本地没问题,扔到服务器上开始报异常“无法加载sqlserverspatial.dll”,一时蛋疼菊紧。难道还得装个sql server的服务吗。。。显然不用- -留下点笔记以备后用。。

    Any application that uses Entity Framework’s spatial data type support to target SQL Server requires the ‘CLR Types for SQL Server’ to be available on the machine the application runs on. This also applies to applications that use SQL Server spatial data types directly, without using Entity Framework.(就是说想用SQL Server的空间模块功能一般得装个CLR Types for SQL Server)

    When developing your application the CLR Types for SQL Server are usually installed system-wide, since they are included in Visual Studio. Issues arise when you try to deploy to a machine that does not have the CLR Types for SQL Server installed. Initially you will get the following InvalidOperationException.

    Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.

    If you were to find and deploy the Microsoft.SqlServer.Types assembly you’ll then get the following DllNotFoundException.

    Unable to load DLL 'SqlServerSpatial110.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) ()

    (正常思路是引用Microsoft.SqlServer.Types.dll就以为OK了。。然而依然会有异常

    解决方案:

    安装 Microsoft.SqlServer.Types NuGet package

    PM> Install-Package Microsoft.SqlServer.Types
    然后项目下出现:
    看看readme就啥都解决了。。。
    大致就是说想跑起来的话你可以提前加载SqlServerSpatial110.dll这样就不需要装System CLR Types for SQL Server了
    然后这个分32位和64位的
    然后如果是web可以在程序入口Globle,starup啥的加个 SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
    如果是桌面应用啥的就在起始加个SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
     
    最近部署时又蹦出来个Bug:
    大致意思就是加载这个程序集“Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91“的时候没找到,

    打开引用仔细看了看,明明哪里都是版本11.0.0.0

    解决方式:

    在配置文件中添加对指定程序集

     <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
            <bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
  • 相关阅读:
    风机故障诊断分析方案
    sklearn机器学习的监督学习的各个模型主要调参参数
    由于下载fiddler导致,有网而网页无法访问,解决方法是导入fiddler的代理证书,具体步骤参考下面博客
    主题建模:隐含狄利克雷分布
    pytorch坑
    sklearn学习总结
    C# 串口模拟键盘输入
    C#求 鸡兔同笼 已知鸡兔总头数,总脚数为x,求鸡兔各多少只?
    C#图像显示实现拖拽、锚点缩放功能[转 有耐心的小王]
    C# WinForm窗体及其控件自适应各种屏幕分辨率
  • 原文地址:https://www.cnblogs.com/ylsforever/p/5159315.html
Copyright © 2011-2022 走看看