fpanaccia / Wkhtmltopdf.NetCore.Example-deprecated

Implementation of Wkhtmltopdf.NetCore
81 stars 33 forks source link

Unable to resolve service for type 'Wkhtmltopdf.NetCore.IGeneratePdf' #11

Open aammfe opened 4 years ago

aammfe commented 4 years ago

Hello !! I'm flowing this blog But having issue bcs DI could not find IGeneratePdf

System.InvalidOperationException: Unable to resolve service for type 'Wkhtmltopdf.NetCore.IGeneratePdf' while attempting to activate 'test.Controllers.WeatherForecastController'

here I have supplied .exe and register Wkhtmltopdf in services image

this is controller code image

Jefferycheng commented 2 years ago

Did you add the property "copy if newer" of the wkhtmlpdf.exe in csproj?

Like this:

  <ItemGroup>
    <None Update="Rotativa\Linux\wkhtmltopdf">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="Rotativa\Mac\wkhtmltopdf">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="Rotativa\Windows\wkhtmltopdf.exe">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>