无法加载文件或程序集'Microsoft.SqlServer.Types甚至使用复制本地

Jso*_*ham 11 c# reference

我有一个关于我的Web应用程序的内部报告,当我浏览它时,本地按预期显示.我使用的是rdlcxsd一个标准的apsx网页呈现报表.

我现在已部署到我的登台服务器,当我尝试浏览到显示我收到的报告的页面时:

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)
Run Code Online (Sandbox Code Playgroud)

在本地,我Microsoft.SqlServer.Types通过浏览添加了一个参考:

C:\ WINDOWS \装配\ GAC_MSIL\Microsoft.SqlServer.Types\11.0.0.0__89845dcd8080cc91

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

出于兴趣,我.dll从我的本地机器复制了它,并将其ftp到登台服务器并进入bin文件夹.然后它暂时工作,直到我做了另一次提交,擦除bin文件夹并返回错误.

它的版本Microsoft.SqlServer.Types在登台服务器的操作系统上可能已经过时了吗?

这里发生了什么?

gen*_*ion 15

它可能正在寻找one of its dependencies你是否确定dll在bin文件夹中.

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

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


Jum*_*zza 12

同样的问题,但问题是app.config中的绑定重定向尚未更新到新版本.通常更新nuget包会自动执行,但是这个nuget包在引用的项目中.简单修复:

<?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>
Run Code Online (Sandbox Code Playgroud)

  • 尽管我有 nuget 包引用的 Microsoft.SqlServer.Types,但我必须手动将上述 assemblyBinding 条目添加到我的 web.config 文件中。该网络应用程序似乎正在尝试从 GAC 加载旧版本,而不是我引用的版本。 (2认同)