【问题标题】:Rotativa [Win32Exception (0x80004005): Access is denied]Rotativa [Win32Exception (0x80004005): 访问被拒绝]
【发布时间】:2014-10-04 12:58:55
【问题描述】:

我正在使用 Rotativa 生成 PDF 格式的视图,它在我的本地主机上完美运行/工作。但是,当部署到 GoDaddy 上的共享主机或我的 Azure 网站实例时,我收到以下错误。

我尝试授予 Rotativa 文件夹中 .exe 的权限,但没有成功,还尝试使用完全信任运行,但仍然出现错误。

错误/堆栈跟踪

Access is denied

描述:执行过程中发生了未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。

异常详细信息:System.ComponentModel.Win32Exception:访问权限为 拒绝

来源错误:

在执行过程中产生了一个未处理的异常 当前的网络请求。有关原产地和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。

堆栈跟踪:

[Win32Exception (0x80004005): 访问被拒绝]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +1789 System.Diagnostics.Process.Start() +6735098
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String 开关,字符串 html) +226
Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext 上下文)+26 Rotativa.AsPdfResultBase.BuildPdf(ControllerContext 上下文) +128
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext 上下文)+19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 过滤器,Int32 filterIndex,ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext 控制器上下文,IList1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult
1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 结果)+9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

控制器

public ActionResult Print(Guid reportId)
{
    var report =  new ViewAsPdf("Index", new { id = reportId}) { FileName = "testReport.pdf" };
    return report;

}

权限 我试图通过完全控制来设置整个文件夹“Rotativa”的权限,现在我得到了这个......

此程序被组策略阻止。如需更多信息,请联系 您的系统管理员

描述:执行过程中发生了未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。

异常详细信息:System.ComponentModel.Win32Exception:此程序 被组策略阻止。如需更多信息,请联系您的系统 管理员

来源错误:

在执行过程中产生了一个未处理的异常 当前的网络请求。有关原产地和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。

堆栈跟踪:

[Win32Exception (0x80004005):此程序被组策略阻止。 有关详细信息,请联系您的系统管理员]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) +1789 System.Diagnostics.Process.Start() +6735098
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String 开关,字符串 html) +226
Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext 上下文)+26 Rotativa.AsPdfResultBase.BuildPdf(ControllerContext 上下文) +128
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext 上下文)+19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 过滤器,Int32 filterIndex,ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext 控制器上下文,IList1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult
1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid
1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 结果)+9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514928 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

2015 年 1 月 13 日更新

我最终切换到 TuesPechkin,这是一个更容易使用的解决方案。 GoDaddy 和 Azure 一样支持 FullTrust,但是 Azure 在运行调用 GDI 的进程方面存在一个已知问题,大多数 wkhtmltopdf 库都会这样做。 TuesPechkin 也无法在 Azure 上运行,因此我从未找到 Azure 网站的解决方案,但 TuesPechkin 在我的 web.config 中设置的 GoDaddy 托管上运行良好。

【问题讨论】:

  • 您是如何在 GoDaddy 上使用 TuesPechkin 完成的?每次尝试都会导致Unable to load DLL 'wkhtmltox.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 错误。你能提供你用来定义你的转换器的代码吗?你用过nuget包吗?您使用了哪些软件包(32 位或 64 位)?谢谢你的帮助。我真的被困住了!
  • 我做到了,仍然感到困惑......一切都在本地完美运行,但在 GoDaddy 服务器上失败。我将 32 位 wmkhtmlox.dll 从部署源中提取出来,并将其发布到 root/Resources;但是,尝试使用 new StaticDeployment(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources")) 查找它失败了。您的部署类是否使用了 TempFolder 或 StaticDeployment?
  • 查看这个线程,它有我使用的代码。 github.com/tuespetre/TuesPechkin/issues/57 Tues 的最新版本已修复为包含 dll 的嵌入式版本。我使用了 TuesPechkin.Wkhtmltox.Win32 nuget 包。
  • 是的,我也看到了。 static IConverter converter = new ThreadSafeConverter(new RemotingToolset&lt;PdfToolset&gt;(new Win32EmbeddedDeployment(new TempFolderDeployment()))); public static byte[] GetPDF(HtmlToPdfDocument document) { return converter.Convert(document); } 也失败了

标签: c# asp.net asp.net-mvc-5 rotativa


【解决方案1】:

我认为 GoDaddy 和 azure 网站都不允许“完全信任”IIS 托管模式,这是运行 wkhtmltopdf 进程所必需的。 如果您想使用 Rotativa,您应该寻找提供完全信任访问权限的托管服务提供商。

【讨论】:

  • 他们确实允许这样做,我已经确认这不是问题。
  • 好的,应该是访问权限有问题。 “此程序被组策略阻止。有关详细信息,请联系您的系统管理员”。您应该询问他们是否允许执行 exe 进程。
  • 我最终切换到 TuesPechkin,这是一个更容易使用的解决方案。 GoDaddy 和 Azure 一样支持 FullTrust,但是 Azure 存在一个已知问题,即运行调用 GDI 的进程,大多数 wkhtmltopdf 库都会这样做。 TuesPechkin 也不能在 Azure 上运行,所以我从未找到 Azure 网站的解决方案,但 TuesPechkin 在我的 web.config 中设置的 的 GoDaddy 主机上运行良好。
【解决方案2】:

对我来说,我通过在文件 wkhtmltopdf.exe 的安全窗格上允许以完全权限访问“每个人”来解决此问题

我希望这对使用本地测试机或虚拟机的人有所帮助。

请注意,您还应该为将保存 pdf 输出的文件夹授予相同的允许权限。

【讨论】:

    猜你喜欢
    • 2016-08-15
    • 1970-01-01
    • 2021-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    • 1970-01-01
    • 2013-03-13
    相关资源
    最近更新 更多