Windows Server 2008 R2 x64 环境上的 WkHtmlToXSharp 错误

发布于 2024-11-17 08:43:23 字数 1289 浏览 5 评论 0原文

WkHtmlToXSharp 是优秀的 Html 到 PDF 转换库 wkhtmltopdf 库的 C# 包装器(使用 P/Invoke)。 https://github.com/TobiTonner/WkHtmlToXSharp

我有两个关于暂存 Windows Server 2008 R2 x64 环境的网站 其中一个网站是A版本的网站,另一个网站是B版本。

WkHtmlToXSharp 转换在 A 版本上运行,但是当我设置 B 版本时,转换无法在该版本上运行,我收到错误:

HtmlToPdf conversion failed: Failed loading page http://website/Convert (sometimes it will work just to ignore this error with --load-error-handling ignore)

我想知道为什么会这样正在发生,然后我指向 A 网站查找与 B 网站正在查找的文件夹相同的文件夹。令我惊讶的是,当我运行 A 转换时运行良好,但是当我破坏 B 时,我仍然遇到相同的错误,但有趣的是,两者的站点指向相同的源代码(文件夹)。我只是想知道为什么会发生这种情况。这两个网站都有相似的应用程序池配置,并且在它们的机器人中启用 32 位应用程序设置得太正确。另外,我试图为两个网站设置相同的应用程序池,但仍然发生同样的事情,网站 A 上的转换正常,但 B 网站上的转换无效。

在我的本地环境(Windows 7 x64)上,如果我设置在两种情况下都有效的相同网站转换。

我还对代码进行了一些更改以忽略错误: converter.ObjectSettings.Load.LoadErrorHandling = LoadErrorHandlingType.ignore; 但它并不能修复错误,唯一的区别是,现在我在 B 网站上进行转换时得到空的 pdf。

我只是想可能是 Windows Server 中的某些东西拒绝在内存中运行/保留 WkHtmlToXSharp.dll 或 wkhtmltopdf 的两个副本或类似的情况。

也许有人对此有什么想法?

WkHtmlToXSharp is C# wrapper (using P/Invoke) for the excelent Html to PDF conversion library wkhtmltopdf library. https://github.com/TobiTonner/WkHtmlToXSharp

I have two websites on staging Windows Server 2008 R2 x64 environment
One of them let say web site A version of website and another one web site B.

The WkHtmlToXSharp conversion was working on the A version but when I set up an B version an conversion not working on that version, I am getting an error:

HtmlToPdf conversion failed: Failed loading page http://website/Convert (sometimes it will work just to ignore this error with --load-error-handling ignore)

I was wondering why it is happening and than I pointed A website to look in to the the same folder as B site is looking. And I was surprised that when I am running A conversion working well there, but when I am ruining B I am still getting the same error, but the funny thing is that both of sites pointed to the same source code(folder). I am just wondering why it is happend. Both websites has the similar app pool configurations and Enable 32-bit apps set too true in bot of them. Also i was trying to set the same app pool for both websites and still the same thing taking place, conversion on site A is working but on B site is not.

On my local environment(Windows 7 x64) if I set the same websites conversions working in both cases.

Also I made some changes in code to ignore the errors :
converter.ObjectSettings.Load.LoadErrorHandling = LoadErrorHandlingType.ignore;
but it is does not fix the error, only the difference is that now I am getting empty pdf in case of conversion on B web site.

I just thinking may be it is something in Windows Server which deny to run/keep in memory two copies of WkHtmlToXSharp.dll or wkhtmltopdf or something kind of like that is going on.

Maybe some one have any ideas about that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风情万种。 2024-11-24 08:43:23

请参阅此https://github.com/pruiz/WkHtmlToXSharp/issues/8

IIS 的问题是它会回收应用程序。时不时的泳池,
但在此过程中,您持有的任何非托管资源
应用程序可能(如本例中)最终不适当
释放了。另外,您的 IIS 下有多个 AppDomain
应用程序可能会导致内存损坏,因为两个 AppDomain 都试图
在同一进程下实例化一个 WebKit 实例(即相同
进程内存/空间),这是另一个无路可走。

你能做的最好的事情就是有一个守护进程或服务处理
HTML2PDF 转换,并从您的网络应用程序调用它。使用远程处理,
WS 调用或任何其他 RPC 方法。这也将帮助您分解
您的应用程序并使事情更容易调试。

希望有帮助。

See this https://github.com/pruiz/WkHtmlToXSharp/issues/8

The problem with IIS is that it recycles app. pools from time to time,
but during this process any non-managed resources hold by your
application may (as in this case) end up not being appropiatelly
freed. Also, having more than one AppDomain under you'r IIS
application can cause memory corruption, as both AppDomains try to
instantiante a WebKit instance under the same process (ie. same
process memory/space), and that's another no-way.

The best thing you can do is having a Daemon or Service handling
HTML2PDF conversión, and calling it from your web app. using remoting,
WS calls, or any other RPC method. This will also help you de-compose
your application and making things easier to debug.

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文