❔ Registering a class with string parameter for DI.
This
I have a class
MongoRepository
which accepts a MongoDB database and collection name in the constructor parameters.
How do I fix this file?
I am using this file in the Program.cs
as
i5 Replies
The
mongoDbSettings
is coming null.
My Program.cs part
yes
Aah, this was the issue.
This was the correct line var mongoDbSettings = configuration.GetSection("MongoDb").Get<MongoDbSettings>();
Can you explain what you mean by this? I am an absolute noobYou mean like this?
"No service for type 'Play.Catalog.Service.Entities.MongoDbSettings' has been registered.
I am configuring the
MongoDbSettings
here.
but I get this error 😦
Works like charm!
Thanks @Retax!
Can you refer some material for DI and stuff related to this issue? would appreciate it.Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.