Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

c# - TuesPechkin unable to load DLL 'wkhtmltox.dll'

I've been using TuesPechkin for some time now and today I went to update the nuget package to the new version 2.0.0+ and noticed that Factory.Create() no longer resolved, so I went to read on the GitHub the changes made and noticed it now expects the path to the dll?

IConverter converter =
    new ThreadSafeConverter(
        new PdfToolset(
            new StaticDeployment(DLL_FOLDER_PATH)));

For the past few hours I've tried almost all the paths I can think of, "in", "app_data", "app_start", etc and I can't seem to find or figure out what it wants for the path and what dll?

I can see the TuesPechkin dll in my bin folder and it was the first path I tried, but I got the following error:

Additional information: Unable to load DLL 'wkhtmltox.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Where is that dll and now can I get it as the library doesn't seem to contain it, I tried installing the TuesPechkin.Wkhtmltox.Win32 package but the dll still is nowhere to be found. Also I am using this in a asp.net website project so I assume that using the following should work for obtaining the path, right?

var path = HttpContext.Current.Server.MapPath(@"~inTuesPechkin.dll");

Further information: https://github.com/tuespetre/TuesPechkin/issues/57

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Tuespechkin has a zip file as a resource in the Win32 and Win64 embedded packages for the 'wkhtmltox.dll' file.

What it does when you use the Win32 or Win64 Embedded package is unzips the file and places it in the directory that you specify.

I have been putting a copy of the wkhtmltox dll at the root portion of my web app directory and pointing the DLL_FOLDER_PATH to it using the server physical path of my web app to get to it.

According to the author, you must set the converter in a static field for best results.

I do that, but set the converter to null when I am finished using it, and that seems to work.

Tuespechkin is wrapper for the wmkhtmlox dll file.

The original file is written in C++ and so will not automatically be usable in C# or VB.NET or any of the other managed code domains.

The Tuespechkin.dll file DOES NOT contain a copy of 'wkhtmltox.dll'. You either have to use one of the other embedded deployment modules or install a copy of the 'wkhtmltox.dll' in your web app after downloading it from the internet. That is what I do, and it seems to work just fine.

I am using Team Foundation Server, and attempts to compile code after using the Tuespechkin routines will fail the first time because the 'wkhtmltox.dll' file gets locked, but all you have to do is simply retry your build and it will go through.

I had issues with the 32-bit routine not working in a 64-bit environment and the 64-bit environment not being testable on localhost. I went with the workaround I came up with after examining the source code for Tuespechkin and the Win32 and Win64 embedded deployment packages.

It works well as long as you specify a url for the input rather than raw html.

The older package didn't render css very well.

If you are using a print.aspx routine, you can create the url for it as an offset from your main url.

I don't have the source code I am using with me at this point to offset to your base url for your web application, but it is simply an offshoot of HttpRequest.

You have to use the physical path to find the .dll, but you can use a web path for the print routine.

I hope this answers your question a bit.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...