Search code examples
.netwpfprismunity-container

With Prism, can I use DependencyInjection by Microsoft rather than using either Prism.Unity or Prism.DryLoc?


My .NET 6 WPF application uses Prism.Wpf 8.1.97. I am also using Visual Studio Community 2022 (64bit). I am hesitant to use Prism.Unity because Unity has been deprecated. Because of my experience with the now deprecated Unity, I do not want to use Prism.Unity. I am also wary of DryLoc considering that in the future it could suffer the same fate.

So, I'd rather switch to Microsoft DependencyInjection if it will give me tools similar to Unity. Can I use Microsoft DependencyInjection in lieu of Prism.Unity or Prism.DryLoc?


Solution

  • You can use Prism.Container.Extensions. It seems to work, but it's not recommended for production.

    Prism relies on named registrations, a feature that the Microsoft container does not have. All in all, Microsoft's DI is a very feature-limited container, compared to Unity or Dry-Ioc, more of a proof of concept meant for application examples.

    I'd rather stick with Unity, as it's a mature and very feature-rich container. Even though there won't be new versions in the foreseeable future, it also works just fine.

    Your app shouldn't rely too much on a specific container, anyway, and it should only be used in very, very few classes. So you can always later switch to a different container with minimal effort, if need arises.