I have developed a console application as my web job and also I have developed web API to generate excel, both web job and all the API are in same solution.
I have added reference of Service inside Console application and calling the API.
But here I'm getting issue that in my ExcelRender service class I'm using IHostEnvironment as parameter inside constructor, so when I'm calling that service from web job I'm getting error that,
"Unable to resolve service for type 'Microsoft.AspNetCore.Hosting.IHostingEnvironment' while attempting to activate the ExcelRender service"
If I remove that IHostEnvironment parameter from that service constructor then web job run success without any error.
Inside web job Program.cs file I have injected all my API service using ConfigServices method of HostBuilder.
I have search this error and tried every possible way but not able to resolve it.
So can anyone help me to understand what is the meaning of service not able to activate and how to resolve this ?
When I verified all thing I found that in my web job program.cs class I'm using two reference that Microsoft.AspNetCore.Hosting and Microsoft.Extension.Hosting
In this two dll's we have IHostingEnvironment, but I'm not using IHostingEnviroment any where in my web job, it's present inside my web API service.
So I think it will not create this issue, but not sure.
Please help here, any suggestion valuable for me.
Thanks in advance.