Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
625 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...