简体   繁体   中英

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

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?

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>

Microsoft.SqlServer.Types -Version 14.0.314.76 is the current version. try changing your version number. Second, check your .csproj file, Application also maintains its dependencies in .csproj file

For a net library project that have the same error, I go to NuGet packages and install this library:

Microsoft.SqlServer.Types

and its works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM