【问题标题】:Microsoft.SqlServer.Types' version 10 or higher could not be found找不到 Microsoft.SqlServer.Types 版本 10 或更高版本
【发布时间】:2020-12-07 21:05:20
【问题描述】:

这已经被问过很多次了,但是在遵循this answer 中的建议之后,我仍然没能做到。

我有一个被另一个应用程序调用的类库。这在本地工作没有问题。我使用以下...

SqlServerSpatial140msvcr120 都在各自文件夹的 bin 中。

在调用空间调用之前

SqlServerTypes.Utilities.LoadNativeAssemblies(dlls); // dlls == bin directory 
SqlProviderServices.SqlServerTypesAssemblyName = typeof(SqlGeography).Assembly.FullName;

App.config

<runtime>
  <dependentAssembly>
     <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
   </dependentAssembly>
</runtime>

但是,当部署到服务器上时,我在调用 System.Data.Entity.Spatial.DbGeography.FromText(String wellKnownText) 时得到一个 System.InvalidOperationException

有错误

空间类型和函数不适用于此提供程序,因为找不到版本 10 或更高版本的程序集“Microsoft.SqlServer.Types”。 System.InvalidOperationException:空间类型和函数不适用于此提供程序,因为找不到程序集 'Microsoft.SqlServer.Types' 版本 10 或更高版本。

我在这里错过了什么?

【问题讨论】:

  • 我有同样的问题,我在服务器上安装了 Sql Server Management Studio,这个问题就消失了。如果您无法安装 SSMS,那么您也可以在服务器上安装 Sql Server Developer Tools。试试这个,让我知道它是否有效,我会发布这个评论作为答案。

标签: c#


【解决方案1】:

您是否将bindingRedirect 放置在可执行应用程序App.config 中?类库和其他 DLL 应避免使用 App.config 设置。

更多信息在这里:

https://stackoverflow.com/a/1009227/3850405

这个bindingRedirect 为我工作:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
  <bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>

https://stackoverflow.com/a/44819952/3850405

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-04
    • 2021-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    相关资源
    最近更新 更多