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

JNM*_*JNM 9 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?

Ian*_*emp 18

请参考这个答案.您需要执行以下操作之一:

  1. 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>

  1. 添加bindingRedirectMicrosoft.SqlServer.Typesapp.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.

  • 对于更高版本,请使用NuGet软件包`&lt;package id =“ Microsoft.SqlServer.Types” version =“ 14.0.1016.290” targetFramework =“ net40-client” /&gt;`(并参阅作为软件包一部分安装的ReadMe.htm,以查看操作需要在运行时加载本机程序集)。并且绑定重定向`&lt;dependentAssembly&gt; &lt;assemblyIdentity name =“ Microsoft.SqlServer.Types” publicKeyToken =“ 89845dcd8080cc91” culture =“ neutral” /&gt; &lt;bindingRedirect oldVersion =“ 10.0.0.0-15.0.0.0” newVersion =“ 14.0.0.0 “ /&gt; &lt;/ dependentAssembly&gt;` (3认同)

Chi*_*gum 2

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