fpanaccia / Wkhtmltopdf.NetCore-deprecated

Rotativa + Net Core
The Unlicense
220 stars 94 forks source link

Injecting dependencies using scope #51

Closed thug1705 closed 3 years ago

thug1705 commented 3 years ago

Hi @fpanaccia, firstly thanks for the library.

I am trying to use in my project where I have background task that suppose to generate pdfs for one or more data elements. I am having issues when I am trying to inject depenendencies using service provider. I am trying to do like this

var tempDataProvider = serviceScope.ServiceProvider.GetRequiredService<ITempDataProvider>();
var razorViewEngine = serviceScope.ServiceProvider.GetRequiredService<IRazorViewEngine>();
var razorViewStringRenderer = serviceScope.ServiceProvider.GetRequiredService<IRazorViewToStringRenderer>();
var pdfGenerator = serviceScope.ServiceProvider.GetRequiredService<IGeneratePdf>();

However when I run I am getting following exception

image

Any ideas how to this, am I missing some dependencies ?

gurustron commented 3 years ago

Can you please add full repro somewhere?

thug1705 commented 3 years ago

Hi @gurustron thanks for you respond, unfortunately I can't share source code. Anyway issue was related to my code, rather then library itself therefor I will close the issue.