Could not load file or assembly 'Microsoft.Sql

2020-07-22 16:22发布

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?

标签: c# sql-server
2条回答
欢心
2楼-- · 2020-07-22 16:55

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>
查看更多
相关推荐>>
3楼-- · 2020-07-22 16:56

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

查看更多
登录 后发表回答