无法加载Microsoft.SqlServer.Types 10,但引用了版本11

时间:2014-11-10 05:03:54

标签: c# sql-server

我有一个引用了多个项目的C#应用​​程序。其中一个项目是引用Microsoft.SqlServer.Types(Version 11),因为它使用的是SQLGeometry。当我将我的应用程序安装到空计算机(仅使用VC ++ 2010的Windows 7)时,我的应用程序出错了,它就是"

  

无法加载文件或程序集' Microsoft.SqlServer.Types,   Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91'要么   其中一个依赖。

为什么需要版本10的任何想法?

2 个答案:

答案 0 :(得分:15)

Please refer to this answer.您需要执行以下操作之一:

  1. Type System Version=SQL Server 2012关键字添加到app.config中的连接字符串:
  2. <configuration> <connectionStrings> <add name="YourConnectionStringName" connectionString="(connection string values);Type System Version=SQL Server 2012" /> </connectionStrings> </configuration>

    1. bindingRedirect中为Microsoft.SqlServer.Types添加app.config
    2. <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>

      任一选项都将确保SqlConnection将加载Microsoft.SqlServer.Types程序集的版本11.0.0.0,而不是版本10.0.0.0。

答案 1 :(得分:2)

在解决方案的某个位置,项目(csproj文件)或web / app.config仍然引用版本10.0.0.0。搜索解决方案范围为字符串10.0.0.0,您将找到参考。