Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0' or one of its dependencies

Tags:

c#

sql-server

Recently I have started using SSMS 2017 (v17.5). In my MVC application, I am getting Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. error. Only thing changed in my application is Microsoft.SqlServer.Types version which is 14.0.0.0 now. Previously, it was 12.0.0.0.

Following are different options I have tried so far based on my research (this includes another stackoverflow articles + google) but I am getting same error.

  1. Add <dependentAssembly> in app.config

    <dependentAssembly> <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" /> <bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" /> </dependentAssembly>

  2. Adding following line in Global.asax.cs in Application_Start method.

    SqlProviderServices.SqlServerTypesAssemblyName = "Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";

  3. Installing Microsoft.SqlServer.Types using NuGet.

    PM> Install-Package Microsoft.SqlServer.Types

  4. Searched for 10.0.0.0 referance in entire project but didn't find any referance.

  5. I do have Microsoft System CLR Types for SQL Server installed for 2012, 2014, 2016 and 2017.

What am I missing here?

like image 847
GThree Avatar asked Apr 09 '18 18:04

GThree


1 Answers

After spending almost a day, I was able to fix this issue. From my question above, option-1 worked for me. Only tweak was to add that in web.config instead of app.config. Hope this help someone else.

Code: web.config

<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-14.0.0.0" newVersion="14.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
</runtime>
like image 89
GThree Avatar answered Nov 18 '22 08:11

GThree