Closed Paulskit closed 3 years ago
Transient and scoped objects have the same lifetime as their connections and not view models, so they will only get auto-disposed when the connection terminates. If you need it disposed along with the view model instance, explicitly dispose them in the view model's Dispose method override.
Problem: Transient instances don't get disposed on VM dispose
Steps to Reproduce: 1) Register service as Transient services.AddTransient<IServiceA, ServiceA>();
2) Inject in ViewModel
Since it's transient service, it gets created on every instance of
MyViewModel
. However, it doesn't get disposed when model disposed