---
title: "Discussion on \"Are you using Dependency Injection in your .NET MAUI app yet?\" | Hashnode"
description: "Discussion on \"Are you using Dependency Injection in your .NET MAUI app yet?\". Learn how to leverage the powerful, built-in dependency injection capabilities of .NET MAUI and Shell"
url: "https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/6482f2104778277cfdf5862f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Are you using Dependency Injection in your .NET MAUI app yet?](https://blog.ewers-peters.de/are-you-using-dependency-injection-in-your-net-maui-app-yet?utm_source=hashnode&utm_medium=feed)

Learn how to leverage the powerful, built-in dependency injection capabilities of .NET MAUI and Shell

Jun 9, 2023 · 12 min read · blog.ewers-peters.de  
Updated Oct 25, 2023  
Read the article

-   [#dotnet-maui](https://hashnode.com/tag/dotnet-maui)
-   [#dependency-injection](https://hashnode.com/tag/dependency-injection)
-   [#dotnet](https://hashnode.com/tag/dotnet)
-   [#solid-principles](https://hashnode.com/tag/solid-principles)
-   [#maui-shell](https://hashnode.com/tag/maui-shell)

## Written by

[Julian Ewers-Peters](https://hashnode.com/@ewerspej)

@ewerspej · Germany

  
[View profile](https://hashnode.com/@ewerspej)

Mobile App Developer

I am a passionate mobile app and software developer with a focus on C# .NET, Xamarin.Forms and .NET MAUI.

## Responses 3

Markdown supported · ⌘↵ to post

[Renatas Laužadis](https://hashnode.com/@devmanlab)

[Mar 3, 2024](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/6482f2104778277cfdf5862f/comment/65e4d83cdc15705d19ce854a)

Hi, Julian, why, when registering singleton, are you using Instance for DeviceService, but not for AudioService?

[Julian Ewers-Peters](https://hashnode.com/@ewerspej)

[Mar 28, 2024](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/6482f2104778277cfdf5862f/comment/65e4d83cdc15705d19ce854a#reply-66051ef99609cc27c5eb7bc4)

Hi Renatas,

sorry, I only saw your comment now. Not sure what exactly you mean. In the sample repository, the AudioService isn't implemented, yet, it doesn't use the Singleton Design (anti-) Pattern. I just want to demonstrate different ways to register and use dependencies.

What matters most is that the SOLID principles are applied wherever possible. Now, the code in the samples repository isn't perfect, it's a showcase of possibilities.

Generally, any service with a public @[Object](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/constructor) or factory method can be registered as a singleton, transient or scoped dependency. Note that the term "singleton" is somewhat overloaded here, because in the context of dependency injection, it means that always the same instance will be resolved by the DI container, it doesn't mean the Singleton Design Pattern (SDP). Classes that use the SDP can still also be registered as a singleton dependency, in which case you don't register the @[Object](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/constructor) (because it's private) or a factory (because it doesn't exist), but rather the static singleton instance.

I hope this clears it up a little.

Cheers Julian

[Richard Lavallee](https://hashnode.com/@Sampapi)

[Feb 6, 2024](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/6482f2104778277cfdf5862f/comment/65c225ac71fd64c45ef4004d)

Excellent article. This solved my resolution problem as I needed to resolve a Dependency from a c# Class library. Yes, I would like to know how to mock IDependencyService also, and would appreciate if you wrote a piece on that. Thanks.

[Richard Lavallee](https://hashnode.com/@Sampapi)

[Feb 6, 2024](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/6482f2104778277cfdf5862f/comment/65c225ac71fd64c45ef4004d#reply-65c2455880e54b8980926ac8)

I just figured out how to do this, it was less difficult than I anticipated. Thanks.

[Simon O'Rorke](https://hashnode.com/@SimonORorke)

[Dec 31, 2023](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/6482f2104778277cfdf5862f/comment/6591c6c5bb9e53e89c95f338)

Thanks. This is much clearer than Microsoft's documentation on dependency injection in Maui.

[Stephen York](https://hashnode.com/@steveski)

[Nov 26, 2023](https://hashnode.com/posts/are-you-using-dependency-injection-in-your-net-maui-app-yet/6482f2104778277cfdf5862f/comment/6562c86329658b9b067c2c4e)

This is fine and I understand the approach for an app with a main page but how do you deal with DI for a TabbedPage app? I keep getting an error about having to write a type converter or provide a parameter less constructor. But I need to pass on a view model to my page. I’ve outlined the details on stack overflow on an article net-maui-how-to-use-dependency-injected-pages-form-tabbedpage
