-
Notifications
You must be signed in to change notification settings - Fork 94
Could not load type 'Wkhtmltopdf.NetCore.HtmlAsPdf' #34
Comments
Hi! @jlfjunior yeah, that class do not exist anymore. Since version 2.0 now works like a service, so you have to inject it, you could take a look at the example project https://github.com/fpanaccia/Wkhtmltopdf.NetCore.Example TL;DR In the startup.cs you have to remove this -> Wkhtmltopdf.NetCore.RotativaConfiguration.Setup(); Then in the controller/service that you are using the HtmlAsPdf, you have to inject this interface IGeneratePdf like this Then where the HtmlAsPdf is used, you could replace it like this Let me know if this helps you |
after the changes other error is presented: An exception of type 'System.Exception' occurred in Wkhtmltopdf.NetCore.dll but was not handled in user code
|
could you post the full stack trace? |
Yes, follows informations below. Exception has occurred: CLR/System.Exception |
As an clean example, i just did this example project, it does not have the binaries of rotativa because of size restriction in the comments. |
hmm it seems like a problem with the HTML....how were you using it before? the HTML, is a razor view or a "hardcoded" HTML? |
I'm using "hardcode" html. when executing the project WebApplication, the same error happens: Exception has occurred: CLR/System.Exception |
are you using omnisharp? i will try it in vscode |
I'm using vscode with omnisharp, I thank you. |
This is my launch.json { |
i will download the version 3.1.7 of net core and try again |
When using your launch.json the same problem occur. PS C:\Users\junior\Downloads\WebApplication1> dotnet --info Runtime Environment: Host (useful for support): .NET Core SDKs installed: .NET Core runtimes installed: To install additional .NET Core runtimes or SDKs: |
my dotnet info, looks like this now .NET Core SDK (reflecting any global.json): Runtime Environment: Host (useful for support): .NET Core SDKs installed: .NET Core runtimes installed: To install additional .NET Core runtimes or SDKs: But still is working fine maybe is the SDK 2.2.207....im gonna try and install it |
When you install visual studio it install a dotnet sdk (if you choose the .net core option). Maybe there was something wrong with your sdk, you can see that now you are running the 3.1.8 version, maybe there was an issue with your installation. |
After install Wkhtmltopdf.NetCore version 3.0.2 to using an project that depend of Wkhtmltopdf.NetCore version 1.1.3 the error happens below.
An exception of type 'System.TypeLoadException' occurred in BankSlip.Api.dll but was not handled in user code: 'Could not load type 'Wkhtmltopdf.NetCore.HtmlAsPdf' from assembly 'Wkhtmltopdf.NetCore, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null'
The text was updated successfully, but these errors were encountered: