I have a Xamarin forms app that is using dryioc for IoC. It seems all my services get disposed as soon as the view is out of scope
This is how I am registering the service in the app.cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterSingleton<IInboxService, InboxService>();;
}
and I resolve it this way in the app.cs
protected override void OnInitialized()
{
_started = DateTime.Now;
InitializeComponent();
InitializeAppSettings();
Container.Resolve<ISyncService>().Init(new List<ISyncableService>
{
Container.Resolve<IInboxService>()
});
}
When I need to use it in a viewmodel I put it in the constructor like so.
public class HomeViewModel {
public HomeViewModel(InboxService inboxService)
{
}
}
The singleton is respected but then it will dispose and create a new one when it needs it. Anyone else run into this ?
Xamarin Version: 5.0.0.2125
Prism Version: 8.1.97
LocIOS Version: 8.1.97