Ad Space — Top Banner

CS1061

C# Programming Language

Severity: Minor

What Does This Error Mean?

CS1061 means you tried to access a method, property, or field on an object, but that member does not exist on that type. For example: calling .ToJson() on a string, when strings have no ToJson() method. The error tells you the type name and the member name that was not found. This is always a compile-time error — your program will not build until it is resolved.

Affected Models

  • .NET Framework
  • .NET Core
  • .NET 5+
  • Visual Studio
  • Visual Studio Code
  • Rider

Common Causes

  • A typo in a method or property name — C# is case-sensitive, so .getname() is not the same as .GetName()
  • The method exists as an extension method but the required 'using' directive for that namespace is missing
  • The variable is typed as a base class or interface that does not have the member — you need to cast to the correct type
  • A method was removed or renamed in a newer version of a library after an upgrade
  • Trying to use a method that only exists in a subclass on a variable typed as the parent class

How to Fix It

  1. Check the spelling and casing of the member name. In Visual Studio, type the object name followed by a dot — IntelliSense will show all available members.

    Scroll through the IntelliSense list to find the correct name. The method you want may have a slightly different name than you remembered.

  2. Check if the method is an extension method from a specific namespace. If so, add the appropriate using directive at the top of your file.

    Common example: LINQ methods like .Where(), .Select(), .ToList() need 'using System.Linq;' to be visible.

  3. Check the declared type of your variable. If it is typed as a base class or interface, you may need to cast it to the more specific type that has the member you want.

    Example: if 'myAnimal' is typed as Animal but you need a Dog method, cast it: ((Dog)myAnimal).Fetch()

  4. If this started after upgrading a NuGet package, check the package's release notes. Methods are sometimes renamed, moved to different classes, or removed in new versions.

    NuGet packages often document breaking changes in their GitHub releases or a CHANGELOG file.

  5. If the member should exist but does not, you may need to add it to the class yourself. Or, if it is a common operation, look for a different built-in method that does what you need.

    Use the Object Browser (View > Object Browser in Visual Studio) to explore all members of any type in your project.

When to Call a Professional

CS1061 is a compile-time error you can fix yourself. IntelliSense in Visual Studio shows all available members — use it to check what is actually available on the type. If the member disappeared after a library upgrade, check the library's changelog for breaking changes and migration steps.

Frequently Asked Questions

Why does IntelliSense show the method but the compiler still gives CS1061?

This can happen when IntelliSense is showing suggestions for one type but your variable is actually a different type. Try rebuilding the project (Ctrl+Shift+B) to force a fresh compile. Also check if the variable was recently changed to a different type — IntelliSense can lag behind actual code changes. If it still fails after a rebuild, look carefully at the declared type of the variable.

What are extension methods and why do they cause CS1061?

Extension methods are methods added to a type by a different class, usually in a separate namespace. They look like regular methods but require a 'using' directive to be visible. The most common example is LINQ: '.Where()', '.OrderBy()', '.ToList()' are all extension methods in System.Linq. Without 'using System.Linq;', these methods are invisible to the compiler and you get CS1061.

The member exists in the documentation but not in my code — why?

The most common reasons: the member was added in a newer .NET version than your project targets, or it is in a NuGet package you have not installed. Check your project's target framework (in .csproj as TargetFramework) and compare it to the version requirements in the docs. Also verify the NuGet package version — the member may have been added in a version newer than what you have installed.