Application cannot load Microsoft.SqlServer.Types Version 13

0

I am having a problem that many people have had before but none of the existing answers seem to work for me.

When I deploy my ASP.NET project I get an error in the event log saying

Could not load file or assembly 'Microsoft.SqlServer.Types, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

To try to rectify this I installed the Nuget package:

PM> Install-Package Microsoft.SqlServer.Types

This didn't work and I get the same error. So then I followed the readme and used Loader.cs to load the files. Again, same problem. What is happening and why don't the usual solutions fix it?

One thing I did note is that my Microsoft.SqlServer.Types.dll is version 11 not 13? If it makes any difference our database is SqlServer 2016 and our machine is running Windows Server 2008

asp.net
sql-server
entity-framework
sql-server-2016
asked on Stack Overflow Dec 1, 2016 by Chris

2 Answers

2

The way I solved this was to to set the SqlServerTypesAssemblyName in my app. I currently set it in my EntityContext constructor [that inherits off DbContext] to ensure its always set

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

Note your version may want to be different.

answered on Stack Overflow Mar 13, 2017 by Chris
0

Make sure you are reference the correct version of assembly.

If not add manually.

Add manually

Once the nuget package is installed you can ensure that the dll reference property is set to 'copy local = true'

answered on Stack Overflow Dec 1, 2016 by KT.Thor • edited Jul 13, 2018 by Matthew Haugen

User contributions licensed under CC BY-SA 3.0