Follow the example in docs
https://video2.skills-academy.com/en-us/dotnet/core/extensions/dependency-injection-usage
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I'm writing simple console application and I have solution and two project in first project I've Program.cs and CallerRestHttp in second project I've few class where I have generic implementation for HttpClientFactory.
What I want to achieve, my goal is inject in class ( second project) ILogger<MyClass> but all the time I have null value and I have no idea what to change.
Can you give me some example, my code looks like:
Program.cs
var builder = new HostBuilder()
.ConfigureServices((host, services) =>
{
services.AddHttpClient();
services.AddTransient<CallerRestHttp>();
services.AddLogging(config =>
{
config.AddDebug();
config.AddConsole();
}).AddTransient<BaseRestClientHttp>();
}).UseConsoleLifetime();
In CallerRestHttp class I've methods to invoke specific method in my 'RestClientService' but my RestClientService class invoke method Get,POST etc. from BaseRestClientHttp class where I have generic implementation and in this class I want to use my ILogger but inject thorugh constructor all the time show me null value.
How can I resolve this problem ?
Thanks for any advice
Follow the example in docs
https://video2.skills-academy.com/en-us/dotnet/core/extensions/dependency-injection-usage