DinkToPdf Net Core无法加载DLL文件 [英] DinkToPdf Net Core not able to load DLL files

查看:52
本文介绍了DinkToPdf Net Core无法加载DLL文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 DinkToPdf 库从html sql服务器数据库生成PDF.

I am try to generate PDF from html sql server database using DinkToPdf library.

在启动文件中,我已添加

In the Startup file I have added

var context = new CustomAssemblyLoadContext();
context.LoadUnmanagedLibrary(Path.Combine(Directory.GetCurrentDirectory(), "libwkhtmltox.dll"));

该行使我在启动Web应用程序时出错

The line gives me error on launching the web app

DllNotFoundException:无法加载DLL'C:\ Program Files \ IIS Express \ libwkhtmltox.dll'或其依赖项之一:找不到指定的模块.(来自HRESULT的异常:0x8007007E)

DllNotFoundException: Unable to load DLL 'C:\Program Files\IIS Express\libwkhtmltox.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(字符串unmanagedDllPath)

System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(string unmanagedDllPath)

DllNotFoundException:无法加载DLL'C:\ Program Files \ IIS Express \ libwkhtmltox.dll'或其依赖项之一:找不到指定的模块.(来自HRESULT的异常:0x8007007E)

DllNotFoundException: Unable to load DLL 'C:\Program Files\IIS Express\libwkhtmltox.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

在可能的情况下尽力提供帮助

Kindly assist wherever you can

推荐答案

我找到了一些解决方法.它们并不完美,但是值得一试,它们确实提供了帮助,并且我能够从SQl Server生成PDF.我将.dll文件放在以下文件夹中,并且可以正常工作.

I found some work-arounds. They are not perfect but worth a try, and they did do help and I was able to generate PDFs from SQl Server. I put the .dll files in the following folder and it worked.

C:\ Program Files \ IIS Express

C:\Program Files\IIS Express

并使用

Path.Combine(Directory.GetCurrentDirectory(), "libwkhtmltox.dll");

我走遍整个路径的另一种方式

The other way I went for the whole Path

context.LoadUnmanagedLibrary(Path.GetFullPath(@"C:\Users\User\source\repos\WebSolution\WebApp\libwkhtmltox.dll"));

他们两个都工作了.但是,我敦促Net Core开发人员在GetCurrentDir上做得很好.或从项目或解决方案文件夹中加载的方法

Both of them worked. However, I urge Net Core developers to work on the GetCurrentDir very well. Or a Method to load from the Project or Solution Folder

Path.Combine(Directory.GetCurrentDirectory(), "libwkhtmltox.dll");

这篇关于DinkToPdf Net Core无法加载DLL文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆