Skip to main content

How to Resolve Error "CS0570: Property, indexer or event is not supported by the language" in C#

The Compiler Error CS0570 is an Interoperability error. The message reads: "Property, indexer or event 'Name' is not supported by the language; try directly calling accessor method 'get_Name'!"

This error occurs when you reference a library written in another .NET language (like C++/CLI or VB.NET) that uses a feature supported by the Common Language Runtime (CLR) but not supported by C#.

The most common culprit is Parameterized Properties. While VB.NET and C++ allow properties to accept arguments (other than standard indexers), C# does not. Therefore, C# cannot use the property syntax obj.Prop. Instead, you must call the underlying accessor methods directly.

Understanding Property Accessors

In .NET, a "Property" is essentially metadata. It tells the compiler: "When you see obj.Name, actually call the method obj.get_Name()."

  • C# Rule: Properties cannot have parameters (unless they are the default indexer this[]).
  • Other Languages: May allow named properties with parameters, e.g., obj.Item(index).

When the C# compiler encounters a reference to a property that violates C# rules, it rejects the property syntax but kindly informs you that the underlying methods (get_Name or set_Name) are still available for use.

Scenario: Parameterized Properties (VB.NET/C++)

Imagine you are referencing a DLL created in C++/CLI or VB.NET. That library contains a class Grid with a named property Cell that takes coordinates.

The "Foreign" Definition (Pseudo-code):

Class Grid
// A named property taking arguments. C# hates this.
Property Cell(x As Integer, y As Integer) As String
Get ...
Set ...
End Property
End Class

Example of error in C#

In C#, you might try to access this like a property or a method, but the syntax fails because C# expects properties to be parameterless.

using ForeignLibrary;

public class Program
{
static void Main()
{
var grid = new Grid();

// ⛔️ Error CS0570: 'Grid.Cell' is not supported by the language;
// try directly calling accessor method 'get_Cell'!
var val = grid.Cell[0, 0];

// This also fails because 'Cell' is technically defined as a property,
// not a method, so you can't use parenthesis on the property name itself
// without the compiler trying to resolve the property first.
// var val2 = grid.Cell(0, 0);
}
}

Solution: Call the Accessor Method Directly

The error message explicitly tells you the name of the method you should use. Every property in .NET compiles down to methods prefixed with get_ and set_. Since C# cannot use the property wrapper, you must invoke these methods manually.

Solution:

using ForeignLibrary;

public class Program
{
static void Main()
{
var grid = new Grid();

// ✅ Correct: Call the getter method explicitly
string val = grid.get_Cell(0, 0);

System.Console.WriteLine($"Value: {val}");

// ✅ Correct: Call the setter method explicitly
grid.set_Cell(0, 0, "NewValue");
}
}
note

Why does IntelliSense show it? Visual Studio IntelliSense might list Cell as a member because it exists in the metadata. However, trying to use it will result in the red squiggly line indicating CS0570. You will often see the get_Cell and set_Cell methods in IntelliSense as well—use those.

Conclusion

CS0570 is a translation issue between .NET languages.

  1. Read the Error: The compiler suggests a fix: "try directly calling accessor method 'get_Name'!"
  2. Change Syntax: Stop trying to use obj.Property.
  3. Use Methods:
    • To Read: Use obj.get_Property(args).
    • To Write: Use obj.set_Property(args, value).