dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

MVVM.Toolkit: How to remove/unregister service from Ioc.Default

Open DhananjayDhamale opened this issue 2 years ago • 3 comments

Describe the bug

Hi All,

We are migrating our class library application from MVVMLight to MVVMToolkit. We were using SimpleIoc container. We need to use Ioc (Microsoft.Toolkit.Mvvm.DependencyInjection) for migration. We need to remove configured services in CleanUp() method of Locator class. Currently, Ioc does not provide any remove or unregister method. Is there any way to remove/unregister service from Ioc.Default?

Regression

7.1.2

Steps to reproduce

Did not try in Sample app.

Expected behavior

There should be way to remove/unregister service from Ioc.Default

Screenshots

No response

IDE and version

VS 2019

IDE version

No response

Nuget packages

  • [ ] CommunityToolkit.Common
  • [ ] CommunityToolkit.Diagnostics
  • [ ] CommunityToolkit.HighPerformance
  • [X] CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

7.1.2

Additional context

No response

Help us help you

Yes, but only if others can assist

DhananjayDhamale avatar Apr 07 '22 17:04 DhananjayDhamale

If it is a net core project, consider using the container of microsoft.extensions.dependencyinjection.

yaofengyang avatar Aug 27 '22 08:08 yaofengyang

I have the same problem, nothing new?

grizoood avatar Nov 03 '23 11:11 grizoood

Ioc does not really do anything more than forwarding to the actual dependency injection service provider. You should directly use the service provider if it supports removing services after it is built. For example, the Microsoft dependency injector does not.

abdes avatar Dec 01 '23 11:12 abdes