我正在尝试使用DinkToPdf库从HTML数据库生成PDF。
在启动文件中,我添加了:
var context = new CustomAssemblyLoadContext();
context.LoadUnmanagedLibrary(Path.Combine(Directory.GetCurrentDirectory(), "libwkhtmltox.dll"));
在启动web应用程序时,这条线给了我这个错误:
DllNotFoundException:无法加载DLL 'C:\Program \IIS Express\libwkhtmltox.dll‘或其依赖项之一:找不到指定的模块。(HRESULT例外: 0x8007007E) System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(string unmanagedDllPath) DllNotFoundException:无法加载DLL 'C:\Program \IIS Express\libwkhtmltox.dll‘或其依赖项之一:找不到指定的模块。(HRESULT例外: 0x8007007E)
发布于 2020-04-10 07:41:32
在Asp.Net核心应用程序中,我像这样使用它来获取运行时的当前目录
#if DEBUG
//windows
string filePath = $@"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\libwkhtmltox.dll";
#else
//linux
string filePath = @$"{(($@"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}/libwkhtmltox.so").Replace(@"\", @"/"))}";
#endif
CustomAssemblyLoadContext context = new CustomAssemblyLoadContext();
context.LoadUnmanagedLibrary(filePath);
serviceCollection.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
#endregion
https://stackoverflow.com/questions/55430532
复制相似问题