【发布时间】:2017-01-04 08:30:44
【问题描述】:
我关注了很多 SO 问题,我遇到了类似的错误,但我无法解决这个问题。
我的 Dapper 版本是 1.50.1 我的 Microsoft.SqlServer.Types 版本是 11.0.2
我在配置文件中添加了绑定重定向,如下:
<runtime>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</runtime>
我得到的错误是:
解析第 2 列时出错(位置=POINT (-122.349 47.651) - 对象)
虽然内部异常是:
[A]Microsoft.SqlServer.Types.SqlGeography 无法转换为 [B]Microsoft.SqlServer.Types.SqlGeography。类型 A 源自 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' 在位置 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types\10.0 的上下文 'Default' 中.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll'。类型 B 源自 'Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' 在位置 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Types\11.0 的上下文 'Default' 中.0.0__89845dcd8080cc91\Microsoft.SqlServer.Types.dll'。
如果我只是读取动态对象,一切都很好,但如果我读取自己的具有 SqlGeography 的类型,我会收到此错误。
我以为我按照建议做了所有事情,但似乎我错过了一些东西。
【问题讨论】:
-
我自己的答案可能重复!
标签: dapper sqlgeography