C# "CS1061: no definition for ..." - API Drift in CI
The type resolved, but the member you called does not exist on it. Usually a dependency upgrade renamed or removed the member, or an extension method’s namespace is not imported so the method is invisible.
What this error means
Build fails with CS1061 saying a type has "no definition for" a member, sometimes adding "no accessible extension method". It is deterministic and commonly appears right after a package upgrade.
Program.cs(18,28): error CS1061: 'IServiceCollection' does not contain a definition
for 'AddRedisCache' and no accessible extension method 'AddRedisCache' accepting a
first argument of type 'IServiceCollection' could be found
(are you missing a using directive or an assembly reference?)Common causes
A dependency renamed or removed the member
An upgraded package changed its API - the method was renamed, moved, or dropped - but the call site still uses the old name.
Extension-method namespace not imported
For "no accessible extension method", the extension lives in a namespace that is not imported, so the method is not in scope even though the package is referenced.
How to fix it
Update the call to the new API
Check the dependency’s changelog and update the member name/signature, or import the extension’s namespace.
// add the namespace that defines the extension method
using Microsoft.Extensions.DependencyInjection;Pin a compatible version if migrating later
When you cannot migrate immediately, pin the dependency to the version whose API the code targets.
<PackageReference Include="StackExchange.Redis.Extensions" Version="9.1.0" />How to prevent it
- Read changelogs when bumping dependencies that you call directly.
- Pin or range-constrain dependencies so APIs don’t shift unexpectedly.
- Import the namespaces that provide the extension methods you use.