C# 无法加载文件或程序集';Microsoft.SqlServer.Types,即使使用“复制本地”

C# 无法加载文件或程序集';Microsoft.SqlServer.Types,即使使用“复制本地”,c#,reference,C#,Reference,我有一个关于我的web应用程序的内部报告,当我在本地浏览到它时,它会按预期显示。我使用标准的apsx网页使用rdlc和xsd来呈现报告 我现在已部署到我的暂存服务器,当我尝试浏览到显示我获得的报告的页面时: An unexpected error occurred in Report Processing. Could not load file or assembly 'Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral,

我有一个关于我的web应用程序的内部报告,当我在本地浏览到它时,它会按预期显示。我使用标准的
apsx
网页使用
rdlc
xsd
来呈现报告

我现在已部署到我的暂存服务器,当我尝试浏览到显示我获得的报告的页面时:

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)
在本地,我通过浏览以下内容添加了对Microsoft.SqlServer.Types的引用:

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

我已经将其设置为
Copy Local
,并且可以在登台服务器上的bin文件夹中看到
.dll
,但是我仍然收到错误消息

出于兴趣,我从本地计算机复制了
.dll
,并将其通过ftp传输到临时服务器和bin文件夹中。然后它暂时起作用,直到我再次提交,删除了bin文件夹并返回错误

它就像Microsoft.SqlServer.Types的
版本在登台服务器的操作系统上已经过时了,也许


这里发生了什么?

如果您确定dll在bin文件夹中,它可能正在查找它的一个依赖项

您是否尝试过删除引用并添加以下NuGet包,而不是从GAC中引用


在升级Visual Studio和Sql Server实例后遇到了相同的问题

重新安装可以下载的SQLSysClrtypes.msiReportViewer.msi软件包后,问题出现了


希望它能帮助一些人。

对我来说也是同样的问题,但是问题是app.config中的绑定重定向没有更新到新版本。通常更新nuget包会自动完成,但此nuget包位于引用的项目中。简单修复:


安装nuget软件包后,从中复制Microsoft.SqlServer.Types.dll C:\Windows\assembly\GAC\U MSIL\Microsoft.SqlServer.Types

将我的web应用程序的文件夹放入主机web服务器。

我无法使用以下代码在新工作站上编译程序

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

问题?微软默认提供的SQL Express服务器在2017年至2019年期间发生了变化,我从未注意到,因此新版本必须设置为新版本=“15.0.0.0”,我复制了该文件

My\u Solution\u Dir)\packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll

进入“/bin”目录。
我的问题解决了。

就在这项工作中,mucho的graciasI不得不手动将上述assemblyBinding条目添加到我的web.config文件中,尽管nuget包引用了Microsoft.SqlServer.Types。似乎web应用程序试图从GAC加载旧版本,而不是我引用的版本。同样,我在web.config中没有引用,但一旦添加了dependentAssembly,它就工作了