CS1061: does not contain a definition for and no extension method
Member lookup failed on both instance and extension methods. Type inference, missing using directives, target frameworks and packages explain most cases.

Introduction & Quick Summary
error CS1061: 'IEnumerable<string>' does not contain a definition for 'ToListAsync'
and no accessible extension method 'ToListAsync' accepting a first argument of type
'IEnumerable<string>' could be found (are you missing a using directive or an
assembly reference?)The compiler resolved the receiver's type, searched instance members, then searched extension methods in scope, and found nothing. The message names both the receiver type and the missing member, so the diagnosis is a matter of asking why that type is what it is.
Five causes cover nearly everything:
- The receiver is not what you expect.
Where()returnedIEnumerable<T>where you assumedIQueryable<T>, so the async extension does not apply. - A missing
using.System.Linq,System.Text.Json, or your own namespace holding the extension method is not imported. - The package is not referenced. The type exists in a NuGet package that is installed for one project but not the one being compiled.
- The target framework lacks the API. A method added in .NET 8 is not available when a library targets
netstandard2.0. - A nullable or
objectreceiver.objecthas almost no members, and a null-conditional chain can degrade an inferred type toobject.
| Receiver type in the error | What probably happened |
|---|---|
IEnumerable<T> | LINQ in-memory chain, not EF Core |
object | dynamic, boxing, or an untyped deserialize |
Task | Missing await before the call |
string | Missing using System; inside a file with implicit usings off |
IDisposable | Interface typed variable, concrete type needed |
Nullable<T> | Dereference without .Value |
Core Mechanics, Signatures & Reproducible Setup
Member lookup order is fixed: instance members on the type, then base types, then extension methods visible through using directives in the current file or namespace, then members brought in by using static. An extension method is only a candidate when the first parameter is assignable from the receiver type, and generic inference can fail for reasons the message does not show.
Reproduce a version of it with two files:
// Extensions.cs
namespace App.Text;
public static class StringExtensions
{
public static string Shout(this string value) => value.ToUpperInvariant() + "!";
}// Program.cs
var s = "hello".Shout();
// error CS1061: 'string' does not contain a definition for 'Shout'Adding using App.Text; or enabling implicit global usings fixes it. A project-level fix is a global using:
// GlobalUsings.cs
global using App.Text;For the EF Core variant, the types must line up exactly:
using Microsoft.EntityFrameworkCore;
IQueryable<Order> query = db.Orders.Where(o => o.Total > 0);
var list = await query.ToListAsync(); // compiles
IEnumerable<Order> materialized = query.AsEnumerable();
var bad = await materialized.ToListAsync();
// CS1061: 'IEnumerable<Order>' does not contain a definition for 'ToListAsync'AsEnumerable() and ToList() drop to in-memory LINQ, which has no async operators. Use ToListAsync() before materializing, not after.
Key Comparison Table
| Situation | Receiver type | Applies to | Fix |
|---|---|---|---|
System.Linq missing | string | Select, Where on arrays | using System.Linq; |
| EF async operators | IEnumerable<T> | ToListAsync | Keep IQueryable<T> |
| Custom extension | Your type | Your method | using the namespace |
| Missing package | Any | Type from NuGet | dotnet add package |
| Older TFM | string | Contains(char, StringComparison) | Multi-target or conditional compilation |
| Nullable receiver | T? | Any instance member | Guard or ! |
| Fix approach | Scope | Risk | When to prefer |
|---|---|---|---|
Add using | Single file | None | Fastest |
| Global using | Whole project | Namespace pollution | Repeatedly needed namespaces |
| Explicit interface cast | Single call | Runtime cast failure | Variable typed too broadly |
| Multi-target | Library | Build time doubles | Distributing a package |
| Package reference | Project | Version conflicts | Genuinely missing assembly |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
Case 1: Task used as Task<T>
var order = repository.GetOrderAsync(id);
var id = order.OrderId; // CS1061: 'Task<Order>' has no definition for 'OrderId'The fix is await, and the enclosing method must be async:
var order = await repository.GetOrderAsync(id);
var id = order.OrderId;Case 2: API differences across target frameworks
string.Contains(char) arrived in .NET Core 2.1, and Contains(string, StringComparison) only in .NET Core 2.1 as well. A library targeting netstandard2.0 cannot use them:
#if NETSTANDARD2_0
value.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0;
#else
value.Contains(needle, StringComparison.OrdinalIgnoreCase);
#endifOr use IndexOf unconditionally, which exists everywhere and avoids conditional compilation.
Case 3: Implicit usings made a project compile locally only
Projects created from .NET 6 templates enable ImplicitUsings and quietly import System, System.Linq, System.Collections.Generic and others. A file copied into an older project, or a project with <ImplicitUsings>disable</ImplicitUsings>, fails on methods that used to be free:
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>Prefer explicit usings in shared code so the dependency is visible.
Case 4: dynamic and COM interop
dynamic payload = JsonSerializer.Deserialize<object>(json)!;
var name = payload.Name; // resolves at runtime, no CS1061With dynamic the compiler stays silent and the call fails at runtime with RuntimeBinderException. If you see CS1061 instead, the type is statically known, so there is no ambiguity to chase.
Case 5: Interface versus concrete type
IList<string> items = GetItems();
var capacity = items.EnsureCapacity(10); // CS1061: IList has no EnsureCapacityEnsureCapacity is on List<T>. Either change the variable's declared type or cast, accepting a possible InvalidCastException:
var list = items as List<string> ?? items.ToList();
var capacity = list.EnsureCapacity(10);Case 6: Extension method shadowed by an instance method
An instance method with a compatible name always wins, even when its signature does not match your call. A type with Select(string) blocks an extension Select(Func<...>) from being chosen, and the error reports no overload rather than pointing at the extension. Check with typeof(MyType).GetMethods() before assuming the extension is out of scope.
Common Compilation/Runtime Mistakes & Version Gotchas
System.Linqis imported by implicit usings, butSystem.Linq.Asyncis a separate package.ToListAsynconIAsyncEnumerable<T>needs it, and the error text looks identical to the EF Core case.- EF Core 6 to 8 changed overloads.
ExecuteDelete,ExecuteUpdateand bulk operations need a newer provider; using them against an older one gives CS1061 onDbSet<T>, not a version error. - Nullable reference types.
string? xstill exposesstringmembers, butx!chains can hide the real null flow. Enable<Nullable>enable</Nullable>and let the compiler warn earlier. - Reference assemblies from a wrong SDK. Visual Studio can compile against a reference assembly pack that does not match the runtime;
dotnet --infoand the project'sTargetFrameworkmust agree. - Kotlin-style extension confusion. C# extension methods cannot override instance members and cannot add static members to a type; attempts always yield CS1061.
- Source generators. A generated extension lives in a namespace defined by the generator; missing the package silently removes it while the call site still compiles against the old binary until a clean rebuild.
When a type mismatch drives the error, log GetType().FullName at runtime or inspect the intermediate type with the debugger, then compare the two candidate JSON payloads using the JSON formatter. If the difference came from a configuration switch such as a different serializer or API version, the diff tool over the two project files shows it in one pass. For reviewing the exact HTTP contract that produced an unexpected DTO, the status code reference settles whether the body is even valid for the verb.
Primary references: CS1061 in the C# compiler message reference explains the lookup rules, and extension methods documents scope and binding precedence.
Official references
primary documentationThe C# documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit C# work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related C# guides
All C# guidesC# CS0117: 'X' does not contain a definition for 'Y'
CS0117 means the compiled assembly has no such member, usually from an older target framework or package. Check the API surface before editing code.
C# CS0246: The type or namespace name could not be found
CS0246 is a compile-time resolution failure: a missing using, package, target framework, or an unrestored project. Trace it backward from the symbol.
C#: NullReferenceException: Object reference not set
The message never names the null. Read the stack trace, enable nullable reference types, and use null-conditional access instead of guessing.
.NET: The framework 'Microsoft.NETCore.App' was not found
A framework-dependent app asks for a runtime major that is absent. Install the matching runtime or publish self-contained, and match Docker tags.
More in C#
All C# guidesThe guides filed next to this one in C#, in library order.