An unhandled exception occurred while processing the request. Exception: Rotativa.AspNetCore.WkhtmlD

asp.net 5.0 (asp.net core 5.0) 在使用 Rotativa 进行HTML 转PDF 操作时,页面报出以下错误:

An unhandled exception occurred while processing the request.
Exception:
Rotativa.AspNetCore.WkhtmlDriver.Convert(string wkhtmlPath, string switches, string html, string wkhtmlExe)
Stack 
Query 
Cookies 
Headers 
Routing
Exception:
Rotativa.AspNetCore.WkhtmlDriver.Convert(string wkhtmlPath, string switches, string html, string wkhtmlExe)
Rotativa.AspNetCore.WkhtmltopdfDriver.ConvertHtml(string wkhtmltopdfPath, string switches, string html)
Rotativa.AspNetCore.ViewAsPdf.CallTheDriver(ActionContext context)
Rotativa.AspNetCore.AsResultBase.BuildFile(ActionContext context)
Rotativa.AspNetCore.AsResultBase.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitR

反复检查多遍,没有找到问题在哪,因为在本地运行是完全没问题的,但是放到服务器上时,就会报出上述错误。打了日志后,发现接口并没有报错,我就怀疑是运行环境应该是有破损,所以更新了下服务器上的公共语言运行时(Common language runtime)——》但发现没用,
于是乎去找资料,功夫不负有心人,终于让我在墙外某论坛找到了一个类似的情况,最后检查后发现少了一个包,(Microsoft Visual C++ Redistributable 2019 (x86)) 注意,根据项目的版本号找对应的包 我的是2019 所以找的是 Microsoft Visual C++ Redistributable 2019 (x86) 如果你的项目比较老,要考虑低的版本号,如Microsoft Visual C++ Redistributable 2015 / 2017。 ( PS: 无论你服务器系统是32位还是64位,都要装X84 版本的(32位),别问我为什么。因为我也不清楚… 看到论坛内的大佬特意提出来的,加上我时间也比较紧,就没有去验证。感兴趣的朋友可以去验证下,结果有啥区别,了解后记得评论区分享下哦。哈哈…)。

废话不多说了,如果你遇到上述和我类似的问题,那就是,缺少了 Microsoft Visual C++ Redistributable 2019 (x86) 包。
知道你懒,诺 拿去:https://download.csdn.net/download/qq_41864148/20222625?spm=1001.2014.3001.5503 (PS:如果手里有积分的,可以友情赞助点,没有的,就算啦。在评论区留下评论/发私信 我会把安装包发给你的。)

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值