CommunityToolkit / CommunityToolkit/dotnet
Keyed Services Support in MvvmToolkit.Mvvm
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 400
- PR merge metrics
- No merged PRs in 30d
Description
### Discussed in https://github.com/CommunityToolkit/dotnet/discussions/800
Originally posted by **Touseefelahi** November 23, 2023
How to use keyed services in my Avalonia Application?
I am trying to use the keyed services feature from .net 8, but it is not working for me.
This is what I have in my App.axaml.cs file
```
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using CommunityToolkit.Mvvm.DependencyInjection;
var services = new ServiceCollection();
services.AddKeyedTransient(ServiceList.LocalDB);
Ioc.Default.ConfigureServices(ConfigureServices());
```
This is how I am trying to get the keyed service in some other class
```
Ioc.Default.GetRequiredKeyedService("LocalDB");
```
This is the error that I am getting:
`This service provider doesn't support keyed services.
`
Am I missing something here? or the feature is not implemented yet?
Thank you
Contributor guide
Assessment
This issue has not been assessed yet.