rdvojmoc / DinkToPdf

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
MIT License
1.09k stars 417 forks source link

"Unable to load DLL 'C:\Program Files\IIS Express\libwkhtmltox.dll' or one of its dependencies" on .Net Core 2.2 when using InProcess hosting model. #64

Open fabs-rodriguez opened 5 years ago

fabs-rodriguez commented 5 years ago

In .Net Core 2.2, when using the new InProcess hosting model:

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
  <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

I get the following error when launching the project from Visual Studio 2017 (version 15.9.3):

System.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)'

Source: System.Private.CoreLib

Targety Site: {IntPtr InternalLoadUnmanagedDllFromPath(System.String)} | System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}

Stack Trace: at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath) at System.Runtime.Loader.AssemblyLoadContext.LoadUnmanagedDllFromPath(String unmanagedDllPath) at PropWorx.API.Utility.CustomAssemblyLoadContext.LoadUnmanagedDll(String unmanagedDllName) in C:\Users\fabsr\Source\Repos\PropWorx.API\PropWorx.API\Utility\CustomAssemblyLoadContext.cs:line 18 at PropWorx.API.Utility.CustomAssemblyLoadContext.LoadUnmanagedLibrary(String absolutePath) in C:\Users\fabsr\Source\Repos\PropWorx.API\PropWorx.API\Utility\CustomAssemblyLoadContext.cs:line 14 at PropWorx.API.Startup.ConfigureServices(IServiceCollection services) in C:\Users\fabsr\Source\Repos\PropWorx.API\PropWorx.API\Startup.cs:line 131

If I remove the <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> line then everything is fine again.

When publishing the API to our server (Windows Server 2016) I get this error when calling the API:

An error occurred while starting the application. .NET Core 4.6.27110.04 X64 v4.0.0.0 | Microsoft.AspNetCore.Hosting version 2.2.0-rtm-35687 | Microsoft Windows 6.3.9600 | Need help?

ghost commented 5 years ago

Maybe that dll file wasn't packaged with the publish. I got a similar problem when publishing as a portable self-contained app.

I found the dll here : image

Casimodo72 commented 5 years ago

Have you checked the following points https://github.com/rdvojmoc/DinkToPdf/issues/67#issuecomment-461375329 ? Maybe also take a look at the following recipie: https://github.com/rdvojmoc/DinkToPdf/issues/70

olehspidey commented 5 years ago

https://github.com/rdvojmoc/DinkToPdf/issues/76#issuecomment-518975970

ABakumenko commented 4 years ago

download this on server, where you try to use libwkhtmltox.dll https://support.microsoft.com/ru-ru/help/2977003/the-latest-supported-visual-c-downloads