dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

Keyed Services Support in MvvmToolkit.Mvvm

Open Touseefelahi opened this issue 2 years ago • 0 comments

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<IUnitOfWork, UnitOfWork>(ServiceList.LocalDB);
Ioc.Default.ConfigureServices(ConfigureServices());

This is how I am trying to get the keyed service in some other class

Ioc.Default.GetRequiredKeyedService<IUnitOfWork>("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

Touseefelahi avatar Nov 30 '23 05:11 Touseefelahi