如何解决检查可以在 HiQPdf.dll 程序集附近找到“...\HiQPdf.dep”资源文件,并且用户对该文件具有读取和执行权限
我正在使用 HiQPdf 插件在 ASP.NET MVC 应用程序上将页面(客户发票)转换为 pdf。它在本地主机上运行良好,但在我将其发布到 Godaddy 共享托管服务器后抛出错误。这是它抛出的错误:
错误 0x4EC。检查可以在 HiQPdf.dll 程序集附近找到“G:**\domain.com\Content\HiQPdf.dep”资源文件,并且用户对该文件具有读取和执行权限。如果您将 HiQPdf.dep 放在不同的位置,请调用 SetDepFilePath() 方法
我从昨天开始一直在搜索,但没有结果,我已经确认 HiQPdf.dep 存在于 Content 文件夹中,这些是我尝试过的并且都在本地工作,但都没有在 GoDaddy 上解决问题:
-
将 HiQPdf.dep 复制到 Content 文件夹并使用 SetDepFilePath() 方法引用它。
//初始化模型 var 模型 = _db.Invoice.Where(x => x.InvoiceId == invoiceId && !x.Draft) .ToArray().Select(x => new InvoiceVM(x)).FirstOrDefault();
// convert a page to string (update the path to the right page) string html = RenderViewToString(ControllerContext,"~/views/home/_InvoiceDoc.cshtml",model); // start creating pdf doc // the base URL to resolve relative images and css string thisPageUrl = this.ControllerContext.HttpContext.Request.Url.AbsoluteUri; string baseUrl = thisPageUrl.Substring(0,thisPageUrl.Length -"Home/ConvertThisPagetoPdf".Length); // instantiate the HiQPdf HTML to PDF converter HtmlToPdf htmlToPdfConverter = new HtmlToPdf(); htmlToPdfConverter.SetDepFilePath(Server.MapPath("~/Content/HiQPdf.dep")); // render the HTML code as PDF in memory byte[] pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(html,baseUrl); // send the PDF file to browser FileResult fileResult = new FileContentResult(pdfBuffer,"application/pdf"); fileResult.FileDownloadName = "Invoice-" + model.InvoiceNumber + ".pdf"; return fileResult;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。