所标识的项之一格式无效-Microsoft.SqlServer.Type [英] One of the identified items was in an invalid format - Microsoft.SqlServer.Type
问题描述
我正在尝试使用以下方法从SQl Server 2012数据库中检索地理数据:
I'm trying to retrieve geography data from my SQl Server 2012 DB with:
new SqlDataAdapter("SELECT [SpatialColumn] FROM [SpatialTable]", myConnection).Fill(myDatatable);
当数据是Sql Server 2008地理类型(例如Polygon
)时,它们都可以正常工作.但是,当类型为新的CurvePolygon
时,该行代码将因错误而崩溃:
When the data is a Sql Server 2008 geography type such as Polygon
, it's all working fine. But when the type is the new CurvePolygon
then that line of code crashes with the error:
System.FormatException occurred
Message="One of the identified items was in an invalid format."
Source="Microsoft.SqlServer.Types"
StackTrace: at Microsoft.SqlServer.Types.GeoData.Read(BinaryReader r)
在 MSDN文章中,在名为的部分中SQL CLR数据类型我已经读到,当您引用SqlTypes程序集版本11.0,并且还安装了版本10.0时,您可能会看到类似的错误.因此,我按照说明更改了配置文件.但这并没有解决我的问题.
In this MSDN article, in the section called SQL CLR Data Types I have read that when you reference the SqlTypes assembly version 11.0, and version 10.0 is also installed, you may see a similar error. So I changed my Config file as explained. But it hasn't solved my issue.
任何想法都非常感谢!
推荐答案
您可以尝试以下绑定重定向:
You can try the following binding redirect:
<assemblyBinding>
<!--....-->
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
加载组件似乎有问题.此处更多内容: http://blog.devart.com/adventures-of-clr-types-in-net-framework.html
It looks like there is a problem with the loading assembly. More here: http://blog.devart.com/adventures-of-clr-types-in-net-framework.html
这篇关于所标识的项之一格式无效-Microsoft.SqlServer.Type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!