Rotativa组件引发错误在MVC项目中生成pdf时无法加载文件或程序集'System.Web.Mvc,Version = 3.0.0.1 [英] Rotativa component throws error Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.1 while generating the pdf in MVC project

查看:116
本文介绍了Rotativa组件引发错误在MVC项目中生成pdf时无法加载文件或程序集'System.Web.Mvc,Version = 3.0.0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用此组件根据动态视图内容生成pdf文档.在DEV和Staging环境中进行测试时,它运行良好,而在Production环境中,则抛出以下所示的错误.

I have used this component to generate a pdf document based out of a dynamic view content. On testing at DEV and Staging environment, it worked fine and on Production environment, it throws below shown error.

无法加载文件或程序集' System.Web.Mvc,版本= 3.0.0.1,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040)

Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Rotativa版本:1.0.0.0

Rotativa Version: 1.0.0.0

System.Web.Mvc版本:5.2.3.0

System.Web.Mvc Version: 5.2.3.0

我在web.config中给出了绑定重定向,如下所示.

I have given the binding redirect in web.config as below.

bindingRedirect oldVersion ="0.0.0.0-5.2.3.0" newVersion ="5.2.3.0"

代码:

var pdfLetter = new Rotativa.ViewAsPdf(viewName, viewModel);

pdfLetter.FileName = fileName;

pdfLetter.PageSize = Rotativa.Options.Size.A4;

pdfLetter.PageOrientation = Rotativa.Options.Orientation.Portrait;

pdfLetter.PageMargins = new Rotativa.Options.Margins { Left = 4, Right = 1 };

var letterBytes = pdfLetter.BuildPdf(ControllerContext);

return letterBytes;

Web应用程序未在任何地方引用3.0.0.1版本,并且仍然引发错误.试图检查可用的堆栈溢出线程以进行修复.

Web Application is not referencing the 3.0.0.1 version anywhere and still it throws the error. Tried to check the available Stack Overflow threads to fix.

有人遇到过同样的问题,并且有任何解决方法可以解决吗?

Does anyone encountered this same problem and have any workaround to fix?

推荐答案

两个环境之间的MVC重定向存在配置值不匹配,系统无法识别它.通过从头开始创建web.config重定向部分来解决此问题.

There was config value mismatch for MVC redirect between two environments and system was not able to recognize it. Fixed the issue by creating the web.config redirect section from the scratch.

这篇关于Rotativa组件引发错误在MVC项目中生成pdf时无法加载文件或程序集'System.Web.Mvc,Version = 3.0.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆