Delivery and Deployment, Hands On Labs

HOL02 Hands-On Lab: Leveling Up - Dependency Injection in .NET


8:30am - 12:30pm

Level: Introductory to Intermediate

Jeremy Clark

Developer Educator

Loosely coupled code is easier to maintain, extend, and test. Dependency Injection (DI) helps us get there. In this workshop, we'll see how interfaces can add ""seams"" to our code that makes it more flexible and maintainable. From there, we'll dig into loose coupling with Dependency Injection. DI doesn't have to be complicated. With just a few simple changes to our constructors or properties, we can have code that is easy to extend and test.

After laying a good foundation, we'll take a closer look by diving into various DI patterns (such as constructor injection and property injection) as well as other patterns that help us handle interception and optional dependencies. Along the way, we'll see how DI helps us adhere to the SOLID principles in our code. We'll also we'll look at common stumbling blocks like dealing with constructor over-injection, managing static dependencies, and handling disposable dependencies.

Throughout the day, we'll go hands-on with labs to give you a chance to put the concepts into action.

If you're a C# developer who wants to get better with concepts like abstraction, loose coupling, extensibility, and unit testing, then this is the workshop for you.

You will learn:

  • How and why of dependency injection (DI)
  • Software patterns (such as the Decorator) that make features easy to compose
  • Getting over common stumbling blocks like over injection and handling disposable dependencies

Attendee requirements:

You must provide your own laptap for this hands-on lab.

To get the most out of this hand-on lab, you should have an understanding of the basics C# and object oriented programming (classes, inheritance, methods and properties). No prior experience with dependency injection is necessary.

Hardware & Software:
To participate in the hands-on portion, be sure to bring a laptop and power adapter. Visual Studio 2019 is recommended; you can download the free Community Edition here: (Visual Studio 2017 and other editions of Visual Studio 2019 will also work if you already have one installed.)

The following Workloads should be installed with Visual Studio:

  • ASP.NET and web development
  • .NET desktop development

In addition, we will use .NET Framework 4.7.2 (available here: and .NET Core 2.2 SDK (available here: be sure to get the SDK for your version of Visual Studio).

Be sure to double-check versions of .NET that you have installed prior to hands-on lab.