Skip to main content

How to Resolve Error "CS0514: static constructor cannot have an explicit 'this' or 'base' constructor call" in C#

The Compiler Error CS0514 is a syntax error regarding Constructor Chaining. The message reads: " 'ClassName' : static constructor cannot have an explicit 'this' or 'base' constructor call".

In C#, constructor chaining (using : base(...) to call a parent constructor or : this(...) to call another constructor in the same class) is a feature exclusive to Instance Constructors.

Static Constructors (static ClassName()) work differently:

  1. They are called automatically by the Common Language Runtime (CLR), not by your code.
  2. They initialize the Type itself, not a specific object instance.
  3. They do not participate in the inheritance chain in the same way instance constructors do (you don't "construct" the static part of a base class manually).

Therefore, trying to chain a static constructor to base or this is logically impossible and forbidden.

Understanding Static vs. Instance Construction

  • Instance Constructor (public MyClass()): Runs when you type new MyClass(). It needs to ensure the parent class is initialized first, so it implicitly or explicitly calls base().
  • Static Constructor (static MyClass()): Runs once per application domain, usually before the first instance is created or a static member is accessed. The CLR guarantees that static constructors of base classes run before those of derived classes automatically. You do not need (and cannot use) syntax to enforce this.

Scenario: Trying to Chain a Static Constructor

This error commonly occurs when developers copy-paste code from an instance constructor to a static constructor and forget to remove the inheritance syntax, or when they mistakenly believe they need to manually initialize static members of the parent class.

Example of Code Causing the Error

public class BaseClass
{
static BaseClass()
{
System.Console.WriteLine("Base Static Init");
}
}

public class DerivedClass : BaseClass
{
// ⛔️ Error CS0514: static constructor cannot have an explicit 'this' or 'base' constructor call.
// The syntax ': base()' implies we are calling an instance constructor on the parent.
// Static constructors are not called explicitly.
static DerivedClass() : base()
{
System.Console.WriteLine("Derived Static Init");
}
}

Solution

Simply remove the : base() (or : this()) part. The runtime automatically handles the initialization order of static members (Base first, then Derived).

public class DerivedClass : BaseClass
{
// ✅ Correct: No chaining syntax allowed or needed.
static DerivedClass()
{
System.Console.WriteLine("Derived Static Init");
}
}
note

Execution Order: Even without : base(), if you run this code, the output will naturally be:

  1. Base Static Init
  2. Derived Static Init The CLR handles this dependency for you.

Conclusion

CS0514 is a syntax restriction because static constructors operate outside the normal object instantiation flow.

  1. Check the Constructor: Is it marked static?
  2. Check the Colon: Does it have : base(...) or : this(...) after the parameter list?
  3. Fix: Delete the colon and everything following it up to the opening brace {.