Rob*_*bin 33 iis-7 rotativa asp.net-mvc-5
我有一个ASP.NET MVC 5应用程序.它有一个简单的形式,当用户提交它时,表单存储在缓存中,然后调用另一个控制器操作,此操作将模型作为PDF返回视图.
我没有必要在本地保存它,只是为了在浏览器中显示它,以便用户可以下载它.
也不需要数据库,这就是我将模型存储在缓存中的原因.
在本地,在Visual Studio 2013上,它工作正常.但是当我将它发布到IIS 7时,我得到了一个Unhandled Execution Error
.这是我得到的堆栈跟踪:
Unhandled Execution Error
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception:
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[Exception]
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) +1364
Rotativa.WkhtmltopdfDriver.ConvertHtml(String wkhtmltopdfPath, String switches, String html) +70
Rotativa.ViewAsPdf.CallTheDriver(ControllerContext context) +1986
Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +380
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +69
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248
Run Code Online (Sandbox Code Playgroud)
我第一次使用,ActionAsPDF()
但现在我也尝试使用return new ViewAsPDF()
.两者都给出相同的错误和堆栈跟踪.这是否必须使用权限执行某些操作?
小智 50
此错误是一个名为(MSVCP120.dll)的Visual Studio 2013文件缺少C++可再发行组件包.
要解决这个问题:
打开下面的Visual Studio 2013可下载链接的C++可再发行组件包:下载Visual Studio 2013的 Visual C++ Redistributable软件包
单击下载并选择文件(vcredist_x86.exe),即使您正在运行X64位服务器版本.
安装文件.
查看Jalal W Hijazi博客http://jwhijazi.blogspot.com/2015/05/solving-rotativa-unhandled-exception.html了解更多详情.
小智 16
正如答案中链接的博客评论中所提到的,rotativa
如果您不想/不能在服务器上轻松安装内容,您可以将以下2个dll文件复制到服务器上的文件夹中.
msvcr120.dll
msvcp120.dll
如果它在本地工作,您应该已经有两个dll文件可用.您需要x86版本,如果您发现与vs 2015一起打包的x64版本它们不起作用.我在这里找到了正确的版本:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT
Run Code Online (Sandbox Code Playgroud)
升级到Rotativa 1.7.3后,这已不再适用.我不得不从2017年的视觉工作室复制一些新的dll,我这次在这里找到它们:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT
Run Code Online (Sandbox Code Playgroud)
我不得不复制
msvcp140.dll
vcruntime140.dll
dav*_*esw 10
被接受的答案几乎对我有用。我错过了C ++可再发行的更新版本,因此安装旧版本无济于事。
找出丢失的最简单方法是wkhtmltopdf.exe
手动运行。它将为您提供控制台输出(如果可以)或一个有关缺少内容的消息框。
我缺少MSVCP140.dll,该文件来自VS 2015 Redist,可从此处获取:https : //www.microsoft.com/zh-cn/gb/download/details.aspx? id=48145
小智 5
当我从Rotativa 1.6.4升级到1.7.3时,我在网站应用上的PDF转换停止工作,并且在生产服务器上运行wkhtmltopdf.exe后,我发现它与msvcp140.dll出现问题
解决方案是为Visual Studio 2015安装Visual C ++可再发行组件 https://www.microsoft.com/zh-cn/download/details.aspx?id=48145
归档时间: |
|
查看次数: |
22494 次 |
最近记录: |