我有一个C#应用程序,引用了多个项目.其中一个项目是引用Microsoft.SqlServer.Types(Version 11),因为它使用的是SQLGeometry.当我将我的应用程序安装到空计算机(仅使用VC++ 2010的Windows 7)时,我的应用程序出错,它"
无法加载文件或程序集"Microsoft.SqlServer.Types,Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91"或其依赖项之一.
任何想法为什么需要版本10?
Ian*_*emp 18
请参考这个答案.您需要执行以下操作之一:
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.