maui-dependency-injection SKILL.md skillA
maui-dependency-injection from dotnet/skills is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.
mdr add dotnet/skills/maui-dependency-injection@git:20260728.6d1201cPins git:20260728.6d1201c in mdr.lock. Pin the fingerprint instead.
- Audit grade
- A, 17 of 17 checks passed
- Kind
- SKILL.md skill
- Repository
- dotnet/skills
- Path
plugins/dotnet-maui/skills/maui-dependency-injection/SKILL.md- Versions recorded
- 5
- Latest version
- git:20260728.6d1201c, committed Jul 28, 2026
- First version recorded
- Jul 26, 2026
- Size
- 14,430 bytes
- Repository stars
- 5,836
- License
- MIT
Guidance for configuring dependency injection in .NET MAUI apps — service registration in MauiProgram.cs, lifetime selection (Singleton / Transient / Scoped), constructor injection, Shell navigation auto-resolution, platform-specific registrations, and testability patterns. USE FOR: "dependency injection", "DI setup", "AddSingleton", "AddTransient", "AddScoped", "service registration", "constructor injection", "IServiceProvider", "MauiProgram DI", "register services", "BindingContext injection".
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# Dependency Injection in .NET MAUI .NET MAUI uses the same `Microsoft.Extensions.DependencyInjection` container as ASP.NET Core. All service registration happens in `MauiProgram.CreateMauiApp()` on `builder.Services`. The container is built once at startup and is immutable thereafter. ## When to Use - Registering services, ViewModels, and Pages in `MauiProgram.cs` - Choosing between `AddSingleton`, `AddTransient`, and `AddScoped` - Wiring constructor injection for Pages and ViewModels - Leveraging Shell navigation to auto-resolve DI-registered Pages - Registering platform-specific service implementations with `#if` directives - Designing interfaces for testable service layers ## When Not to Use - XAML data-binding syntax or compiled bindings — use the **maui-data-binding** skill - Shell route registration and query parameters — use the **maui-shell-navigation** skill - Mocking frameworks or test runners — use standard .NET testing tools (xUnit, NUnit, MSTest) and mocking libraries (NSubstitute, Moq) ## Inputs - A .NET MAUI project with a `MauiProgram.cs` file - Knowledge of which services, ViewModels, and Pages need registration …
Read the whole file at its exact version.
How to install
mdr add dotnet/skills/maui-dependency-injection@sha256:0efbf7b9dd6c5da7The line at the top of this page pins the label git:20260728.6d1201c, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
[](https://markdownregistry.com/a/art_cywehpfuvzs7dd5b)
3 badge image fetches in 30 days. What the badge shows.
Versions
The registry has recorded 5 versions of this file, between Jul 26, 2026 and Jul 28, 2026, more than one a day.
| version | committed | commit | size | audit | |
|---|---|---|---|---|---|
| git:20260728.6d1201c latest | 2026-07-28 | 6d1201c | 14,430 B | A | view · diff |
| git:20260727.9c02b41 | 2026-07-27 | 9c02b41 | 13,463 B | A | view · diff |
| git:20260726.746679a | 2026-07-26 | 746679a | 12,116 B | A | view · diff |
| git:20260726.ad057a0 | 2026-07-26 | ad057a0 | 12,075 B | A | view · diff |
| git:20260726.8405072 | 2026-07-26 | 8405072 | 11,812 B | A | view |
Audit of the latest version
- pass: Frontmatter block present
- pass: Frontmatter declares a name
- pass: Frontmatter declares a description
- pass: Size between 200 bytes and 200 KB (14430 bytes)
- pass: No zero-width or bidi control characters
- pass: No instruction hidden inside an HTML comment
- pass: No link to an exfiltration or paste host
- pass: No credential-shaped string
- pass: No instruction to send local credentials anywhere
- pass: No text hidden with inline styles
- pass: No prompt-injection phrasing
- pass: No curl or wget piped into a shell
- pass: No recursive delete of root, home or parent
- pass: No instruction to read or print local credentials
- pass: No base64 blob over 200 characters
- pass: No link to a raw IP address
- pass: No script tag
Source
dotnet/skills · 5,836 stars · license MIT · pushed 2026-11-06 · branch main
API
GET https://markdownregistry.com/api/v1/artifacts/art_cywehpfuvzs7dd5b GET https://markdownregistry.com/api/v1/resolve?ref=dotnet/skills/maui-dependency-injection GET https://markdownregistry.com/api/v1/blob/0efbf7b9dd6c5da7023ba12b3e262f61b6a8d185467cb1cd77150353ce9790f1
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.