CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.96k stars 292 forks source link

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

Open DhananjayDhamale opened 2 years ago

DhananjayDhamale commented 2 years ago

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

Nuget package version(s)

7.1.2

Additional context

No response

Help us help you

Yes, but only if others can assist

yaofengyang commented 2 years ago

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

grizoood commented 10 months ago

I have the same problem, nothing new?

abdes commented 9 months ago

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.