我尝试使用 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文件
发布评论