Skip to main content

How to Resolve Error "CS0551: Explicit interface implementation is missing an accessor" in C#

The Compiler Error CS0551 is an interface compliance error regarding Explicit Interface Implementation. The message reads: "Explicit interface implementation 'Class.Member' is missing accessor 'accessor'".

In C#, an Interface acts as a strict contract. If an interface property defines both a get and a set accessor, any class implementing that interface must provide both. When using Explicit Interface Implementation (prefixing the member name with the interface name), you are defining the implementation specifically for that contract. If you implement only one accessor (e.g., just get) when the interface demands both, the compiler raises CS0551 because the contract is only partially fulfilled.

This guide explains how to fully implement interface properties.

Understanding the Interface Contract

If an interface is defined as:

public interface IConfig
{
int Timeout { get; set; }
}

It means: "Any object claiming to be IConfig must be readable AND writable."

If you implement it explicitly:

int IConfig.Timeout { get { return 10; } }

You are saying: "When treated as IConfig, this object is Read-Only." This directly contradicts the interface definition, which guarantees Write access.

Scenario 1: Missing set Accessor

This occurs when the interface requires read-write access, but the developer only implements read access, perhaps assuming they can leave the setter out if they don't want to support it.

Example of error

public interface ISettings
{
// Interface requires Get AND Set
string Theme { get; set; }
}

public class UserSettings : ISettings
{
// ⛔️ Error CS0551: Explicit interface implementation 'UserSettings.ISettings.Theme'
// is missing accessor 'ISettings.Theme.set'.
string ISettings.Theme
{
get { return "Dark"; }
}
}

Solution: Implement Both Accessors

You must provide the setter. If the logic forbids changing the value, you can throw a NotSupportedException, but the accessor itself must exist to satisfy the compiler.

public class UserSettings : ISettings
{
private string _theme = "Dark";

// ✅ Correct: Both accessors are present.
string ISettings.Theme
{
get { return _theme; }
set { _theme = value; }
}
}
tip

If you don't want it writable: Ideally, change the interface definition to string Theme { get; }. If you cannot change the interface (e.g., it's from a library), implementing the setter to throw throw new NotSupportedException(); is the standard way to handle "Read-Only" behavior on a "Read-Write" contract.

Scenario 2: Missing get Accessor

The reverse is also true. If the interface requires a getter, you cannot provide only a setter.

Example of error

public interface ILogger
{
// Interface requires Get AND Set
string CurrentLog { get; set; }
}

public class FileLogger : ILogger
{
// ⛔️ Error CS0551: Missing 'get' accessor.
string ILogger.CurrentLog
{
set { /* Write to file */ }
}
}

Solution: Implement Both

Provide the missing getter.

public class FileLogger : ILogger
{
// ✅ Correct: Full implementation.
string ILogger.CurrentLog
{
get { return "Log content..."; }
set { /* Write to file */ }
}
}

Conclusion

CS0551 ensures that you don't "short-change" the interface.

  1. Check the Interface: Does it have { get; set; }?
  2. Check your Code: Did you only write { get; }?
  3. Fix: Add the missing block (set or get), even if it just throws an exception or does nothing, to strictly fulfill the signature.