Could not load file or assembly 'Microsoft.SqlServer.Types even with Copy Local

16

I have an internal report on my web application which when I browse to it locally displays as expected. I am using a rdlc and xsd with a standard apsx web page to render the report.

I have now deployed to my staging server and when I try to browse to the page which displays the report I am getting:

An unexpected error occurred in Report Processing.
Could not load file or assembly 'Microsoft.SqlServer.Types, Version=11.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)

Locally, I have added a Reference to Microsoft.SqlServer.Types by browsing to:

C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Types\11.0.0.0__89845dcd8080cc91

And I have set it to Copy Local and can see the .dll in the bin folder on the staging server, however I'm still getting the error message.

Out of interest I copied the .dll from my local machine, and ftp'd it to the staging server and into the bin folder. It then worked, temporarily until I did another commit, which wiped the bin folder and the error returned.

Its like the version of Microsoft.SqlServer.Types is out of date on the staging server's OS perhaps?

What's going on here?

c#
reference
asked on Stack Overflow May 26, 2015 by JsonStatham

5 Answers

20

It's probably looking for one of its dependencies if you're sure the dll is in the bin folder.

Instead of referencing from the GAC have you tried removing the reference and adding the following NuGet package ?

https://www.nuget.org/packages/Microsoft.SqlServer.Types/

answered on Stack Overflow May 26, 2015 by general exception • edited Mar 3, 2021 by Luke Girvin
20

Same issue for me, however the problem was that the binding redirects in the app.config had not been updated to the new version. Usually updating the nuget package does it automatically, but this nuget package was in a referenced project. Simple fix:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings />
  <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <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" /> -->
        <bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
answered on Stack Overflow Jan 4, 2018 by JumpingJezza • edited Aug 6, 2018 by JumpingJezza
1

Experienced the same issue, that has occured after upgrading of Visual Studio and Sql Server instances.

Problem has gone after reinstallation of SQLSysClrtypes.msi and ReportViewer.msi packages, that can be downloaded here

Hope it could help someone.

answered on Stack Overflow May 12, 2016 by Fragment
0

After installing the nuget package, copy the Microsoft.SqlServer.Types.dll from C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Types
to BIN folder of my web application in my Host web server.

answered on Stack Overflow Apr 9, 2018 by Hassan • edited Dec 29, 2020 by Yunnosch
0

I couldn't get my program to compile on the new workstation, by using the following code

    <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>

The issue? The SQL Express server that Microsoft was offering by default, changed from 2017 to 2019 during that time and I never noticed, so the newVersion had to be set as newVersion="15.0.0.0".

answered on Stack Overflow Aug 4, 2020 by Adephx

User contributions licensed under CC BY-SA 3.0