Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load Microsoft.SqlServer.Types 10, but version 11 is referenced

Tags:

c#

sql-server

I have a C# application with multiple project referenced. One of the project is referencing Microsoft.SqlServer.Types (Version 11), because it is using SQLGeometry. When i install my application to an empty computer (Only windows 7 with VC++ 2010) i get an error in my application, that it "

Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies.

Any ideas why it would require Version 10?

like image 869
JNM Avatar asked Nov 10 '14 05:11

JNM


Video Answer


2 Answers

Please refer to this answer. You need to do one of the following:

  1. Add the Type System Version=SQL Server 2012 keyword to your connection string in app.config:

<configuration> <connectionStrings> <add name="YourConnectionStringName" connectionString="(connection string values);Type System Version=SQL Server 2012" /> </connectionStrings> </configuration>

  1. Add a bindingRedirect for Microsoft.SqlServer.Types in 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>

Either option will ensure that SqlConnection will load version 11.0.0.0 of the Microsoft.SqlServer.Types assembly, instead of version 10.0.0.0.

like image 84
Ian Kemp Avatar answered Nov 15 '22 20:11

Ian Kemp


Somewhere in your solution a project (csproj file) or the web/app.config is still referencing version 10.0.0.0. Search solution wide for the string 10.0.0.0 and you will find the reference.

like image 36
Chief Wiggum Avatar answered Nov 15 '22 18:11

Chief Wiggum