0

we are making a Xamarin application that uses PRISM library with DryIoc for DI. We have some services registered as Transient or Scoped in a .NET Core dependency injection simple IServiceCollection, which we adapt onto DryIoc.

The problem that we encounter is that (even if we register a type as Transient), when the container injects dependencies to new Views in the constructor, it injects every time the same instance.

In our overriden implementation of PrismApplication.CreateContainer, we only call base.CreateContainer, and add the .NET Core collection with WithDependencyInjectionAdapter method.

The goal is to create a new instance of the dependencies (a new DbContext for example) in each view creation. How can we achieve that?

AlexDRL
  • 159
  • 6
  • 1
    It is a too broad setup without a failing code sample, so it will be hard to help. Try to repro the problem separately with a bare minimum of sevices and frameworks. – dadhi Jul 11 '17 at 19:40
  • @dadhi We're working on the sample as we try to make that working... I've made a horrible mistake asking the question... the problem is not that the container injects the same implementation of the service to the view, the problem is that the container injects the same instance of the view, and the service is scoped. What we want to achieve is convert ASP.NET Core DI HTTP request-scoped services into view-scoped services, using Xamarin, PRISM and DryIoc. – AlexDRL Jul 12 '17 at 06:29

0 Answers0