我有一个引用了多个项目的C#应用程序。其中一个项目是引用Microsoft.SqlServer.Types(Version 11),因为它使用的是SQLGeometry。当我将我的应用程序安装到空计算机(仅使用VC ++ 2010的Windows 7)时,我的应用程序出错了,它就是"
无法加载文件或程序集' Microsoft.SqlServer.Types, Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91'要么 其中一个依赖。
为什么需要版本10的任何想法?
答案 0 :(得分:15)
Please refer to this answer.您需要执行以下操作之一:
Type System Version=SQL Server 2012
关键字添加到app.config
中的连接字符串: <configuration>
<connectionStrings>
<add name="YourConnectionStringName" connectionString="(connection string values);Type System Version=SQL Server 2012" />
</connectionStrings>
</configuration>
bindingRedirect
中为Microsoft.SqlServer.Types
添加app.config
: <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,您将找到参考。