AddAwsService Not Found | Fix DI Package Mismatch

addawsservice not found points to a missing AWS .NET setup package or a version mismatch in your project.

You hit build, the compiler lights up, and the line that registers AWS clients blows up. This error is rarely mysterious. It almost always comes from three things: the wrong NuGet package, the wrong using directive, or AWS SDK packages that don’t line up.

This guide walks you through a path to get the extension method back, keep your AWS clients wired into dependency injection, and avoid the same trap on the next service you add. You’ll see quick checks first, then a fix for Startup.cs projects and Program.cs hosting with less rework.

AddAwsService Not Found In ASP.NET Core Projects

The method name is easy to misread. In AWS SDK for .NET, the extension method is AddAWSService with AWS in uppercase. Your editor may still show a mixed-case version in suggestions or error text, depending on formatting and the call site. The compiler message tends to say that IServiceCollection has no definition for it.

When that happens, the compiler is telling you a plain fact: the extension method is not in scope. That can be because the package that contains it is not referenced, or because the namespace that exposes it is not imported. A third pattern shows up in bigger solutions: one project references the setup package, another project calls the method, and the calling project never got the dependency.

There’s also a version angle. The AWS SDK has many packages, and mixing major versions can lead to types disappearing or extension methods not resolving the way you expect. If you recently updated a single AWS package and left others behind, treat the whole AWS set as one unit and align versions across the solution.

When Copying Code Between Templates

Copy-paste is where this often starts. A snippet from an older blog might use Startup.cs patterns, a newer app might use minimal hosting, and the registration code ends up in the wrong place. The fix is still the same: reference the right package and place the call on the right service collection for your host style.

Quick Checks Before You Change Code

Start with checks that take minutes and can save you from chasing ghosts. You’re trying to confirm the method exists in your build inputs and that your file can see it.

  • Confirm The Package — In your project file, look for AWSSDK.Extensions.NETCore.Setup. If it’s missing, the extension methods won’t exist.
  • Verify The Using Directive — Add or confirm using Amazon.Extensions.NETCore.Setup; at the top of the file that calls the method.
  • Check The Method Name — Use AddAWSService, not a different casing, and pass an AWS client interface like IAmazonS3.
  • Inspect The Calling Project — If your DI setup lives in a shared library, that library must reference the setup package too.
  • Clean And Rebuild — Clear stale build artifacts with a clean, then rebuild so your IDE refreshes extension method discovery.

If those checks don’t clear it, move to the deeper fix steps below. They target the root cause in most cases and put your project back on a stable, repeatable setup.

Fix The Missing Extension Method In .NET

The extension method lives in the AWS .NET setup package that plugs into Microsoft configuration and dependency injection. If that package is not present, you can’t “bring it back” with a new namespace alone. Install it in the project that compiles the registration code.

Install The Correct NuGet Package

In a terminal at the project folder, add the setup package, then restore.

  • Add The Setup Package — Run dotnet add package AWSSDK.Extensions.NETCore.Setup in the project that contains Program.cs or Startup.cs.
  • Restore Dependencies — Run dotnet restore so the package and its dependencies land in your assets file.
  • Reopen The IDE — Restart your IDE so it refreshes extension method discovery.

Use The Right Namespace

Once the package is present, add the namespace import in the file where you call the method. Without it, the compiler can’t see the extension method while it exists in the build.

  • Add The Import — Include using Amazon.Extensions.NETCore.Setup; near the top of the file.
  • Keep Imports Local — If you use global usings, place it in your global usings file so every project file sees it.

Match AWS SDK Package Versions

If the setup package is installed and the namespace is in place, yet the method still fails to resolve, treat it as a package graph issue. A mixed graph can happen when one AWS package is pinned to a different major line than the setup package or when transitive dependencies pull in older assemblies.

What You See Likely Cause What To Do
AddAWSService missing in one project Setup package not referenced there Add the setup package to the calling project
Extension method still missing after install Namespace import missing Add Amazon.Extensions.NETCore.Setup using
Build errors after upgrading one AWS package Mixed AWS SDK versions in solution Align AWS package versions across projects
Works locally, fails in CI Locked restore file or cache drift Clear caches, restore fresh, pin versions

Version alignment is not about chasing the newest number. It’s about keeping packages on a compatible set so types and extensions line up. If your solution has multiple projects, align AWS package versions in one place, such as Directory.Packages.props, so every project restores the same set.

Make AWS Client Registration Work In Minimal Hosting

In modern ASP.NET Core templates, there is no Startup.cs. Configuration and services live in Program.cs. The AWS setup pattern still works. You add AWS options from configuration, then register AWS service clients through the DI container.

Two lines matter most. One pulls AWS settings from configuration into an AWSOptions instance. The next registers the client interface you want to inject. Your app can then accept interfaces like IAmazonS3 or IAmazonDynamoDB in constructors and the container will create them.

  • Bind AWS Options — Call AddDefaultAWSOptions with options loaded from configuration.
  • Register Service Clients — Call AddAWSService() or the service interface you need.
  • Keep Credentials Flow Simple — Let the default credential chain work on AWS, then override locally through config or profiles.

If you’re on a minimal API, it can be tempting to register everything inline with lambdas. Resist that urge for AWS clients. The AWS setup package already handles lifetime and config wiring. Keep it boring and predictable, and you’ll spend less time on runtime surprises.

Where The Settings Come From

The AWSOptions binding reads settings from the same configuration system your app already uses. That can include appsettings.json, environment variables, and user secrets. On AWS, credentials can come from the runtime, such as an IAM role on an EC2 instance or a task role in ECS.

When you run locally, the SDK can also read shared credentials and config files. That means you can keep keys out of code and rely on profiles. If your app needs a region, set it in configuration so the client knows where to send requests.

Common Edge Cases That Still Trigger The Error

Most cases are fixed with the package and using directive. Some setups add extra friction. These are the ones that keep showing up in real codebases.

Shared Libraries And Multi-Project Solutions

If your web project calls a method that lives in a shared extension class inside a different project, the shared project needs the setup package too. References don’t “flow backward.” The project that compiles the method call must have the extension method available at compile time.

  • Move Registration To The Host Project — Keep AWS client registration in the executable project where Program.cs lives.
  • Add Dependencies Where Code Compiles — If a library calls AddAWSService, install the setup package in that library.

Wrong Target TFM Or Old ASP.NET Core Version

If you’re targeting an older runtime version, you may be using older DI patterns and older AWS packages. The setup package still exists for older runtime versions, yet mixing old runtime version targets with new packages can cause restore rules to pick odd combinations.

  • Check The Target TFM — Confirm the project targets a runtime version that matches the package line you use.
  • Pin Versions Together — Keep AWS package versions aligned with the runtime version you target.

Global Usings And File-Scoped Namespaces

When global usings are enabled, you might assume every file sees the AWS setup namespace. If you placed the using in the wrong file or scope, the call site might still miss it. A quick test is to add the using directly in the file that fails.

  • Add The Using At The Call Site — Put the AWS setup using in the same file as the AddAWSService call.
  • Refresh IDE State — Delete bin and obj folders, then rebuild to refresh generated usings.

A Clean Setup Pattern You Can Reuse

Once the build is green, lock in a pattern that stays tidy as the app grows. The goal is to keep AWS registration in one place, keep versions aligned, and keep configuration readable.

Keep Registration In One Method

Create a single extension method that registers AWS clients and call it from Program.cs. Keep it focused on wiring, not business rules. This way your app startup stays short and every AWS client gets registered the same way.

  • Create One Entry Point — Add a method like services.AddAwsClients(configuration) that wraps AWSOptions binding and client registrations.
  • Register Only What You Use — Add clients for services you call, not every AWS service in the SDK.
  • Review Regions Per Client — If one client needs a different region, pass an AWSOptions instance to that one registration.

Validate The Setup With A Simple Injection Test

Before you deploy, run a small smoke check that builds the host and resolves one AWS client from the container. It doesn’t need to call AWS. It just needs to prove your DI wiring compiles and loads.

  • Build The Host — Start the app and verify it reaches the point where it wires services.
  • Resolve One Client — In a dev-only route or test, ask the container for an AWS client interface.
  • Keep Secrets Out Of Logs — Log only that the client resolved, not keys or tokens.

If you still see the message “addawsservice not found” after these steps, it’s almost always a clue that the file you edited is not the file that compiles the call. Search the solution for the exact method call and fix the project that contains it. Once the correct project references AWSSDK.Extensions.NETCore.Setup and imports the namespace, the error should disappear and your AWS clients will register cleanly.