pruiz / WkHtmlToXSharp

C# wrapper wrapper (using P/Invoke) for the excelent Html to PDF conversion library wkhtmltopdf library.
239 stars 84 forks source link

System.DllNotFoundException: wkhtmltox0 #22

Closed dooburt closed 10 years ago

dooburt commented 10 years ago

Firstly, great library and with a the two interfaces (single and multi-thread) this seems to be the programmers choice for html > pdf.

That being said however, I am struggling to get this to work on a development machine. I get on run 'Exception has been thrown by the target of an invocation' ... DllNotFoundException, Unable to Load DLL 'wkhtmltox0'. Your documentation says this is automatically created on first conversion - perhaps this isn't happening? Or I need permissions on the bin or something? Can you offer any suggestions?

Thanks :)

pruiz commented 10 years ago

Hi dooburt,

There has been some temporal API changes to allow decreasing the final assembly size, and now the native libraries has been split into it's own nuget packages (WkHtmlToXSharp.Win32, etc.). You need to add a reference to the native libraries required by your environmnet (mos probably win32 onyl) and use WkHtmlToXLibrariesManager.Register(..) to register each native bundle before using WkHtmlToXSharp for the first time.

I am still not 100% convenced by this API, and I open to suggestions.. Maybe scanning all AppDomain's assemblies or bin folder for native bundles would be a better idea..

Regards Pablo

On Fri, Feb 28, 2014 at 10:41 AM, dooburt notifications@github.com wrote:

Firstly, great library and with a the two interfaces (single and multi-thread) this seems to be the programmers choice for html > pdf.

That being said however, I am struggling to get this to work on a development machine. I get on run 'Exception has been thrown by the target of an invocation' ... DllNotFoundException, Unable to Load DLL 'wkhtmltox0'. Your documentation says this is automatically created on first conversion - perhaps this isn't happening? Or I need permissions on the bin or something? Can you offer any suggestions?

Thanks :)

Reply to this email directly or view it on GitHubhttps://github.com/pruiz/WkHtmlToXSharp/issues/22 .

dooburt commented 10 years ago

Aha! Thank you. Do you know in what context the file is written? I get System.UnauthorizedAccessException","Message":"Access to the path 'c:\fakepath\invoice-00029.pdf' is denied.". Do you know which user needs permissions for this? IIS_IUSRS?

(btw, fakepath is used for brevity in this example)

pruiz commented 10 years ago

AFAIK if you are running under IIS/Managed ASP.NET, that should be IIS_IUSR, yes..

On Fri, Feb 28, 2014 at 11:03 AM, dooburt notifications@github.com wrote:

Aha! Thank you. Do you know in what context the file is written? I get System.UnauthorizedAccessException","Message":"Access to the path 'c:\fakepath\invoice-00029.pdf' is denied.". Do you know which user needs permissions for this? IIS_IUSRS?

(btw, fakepath is used for brevity in this example)

Reply to this email directly or view it on GitHubhttps://github.com/pruiz/WkHtmlToXSharp/issues/22#issuecomment-36336434 .

dooburt commented 10 years ago

Perfect. Thanks a lot. This is working now :+1: :)

I saw you were using NServiceBus and Wk via a third-party service, if you have a blog or description of that setup I'd be very keen to read it.

Once again, great work.