安装 NuGet 包 PagedList.Mvc 后,应用程序在部署服务器上停止

After installing NuGet package PagedList.Mvc, application stopped on deployment server

我正在开发一个 MVC 5 应用程序,在我开始使用来自 PagedList.Mvc 的寻呼机之前,它 运行 非常好。使用此寻呼机后,该应用程序在开发服务器上运行良好,但是当我将其发布到文件系统并将其部署到另一台服务器上时,出现以下错误:

Could not load file or assembly System.Web.Mvc Version 4.0.0.0

请帮我解决这个错误。

这可能是因为 PagedList.Mvc 是针对 System.Web.Mvc 版本 4.0.0.0 编译的。

尝试使用 bindingRedirect:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="5.2.3.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

只需将第 <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="5.2.3.0"/> 行更新为您的正确版本即可。