Stack overflow 🟪 .NET

.NET: Stack overflow. / Process is terminated due to StackOverflowException

Infinite or very deep recursion exhausted the thread’s stack; .NET can’t catch it and terminates the process.

Seen on: .NET

Meaning

Property getters calling themselves, recursive ToString/Equals, circular object graphs in custom serializers, or DI registrations resolving each other in loops are typical.

Common causes

  • Property that returns itself (get => Name;)
  • Recursive method without a base case
  • Circular references in serialization/ToString
  • Infinite event loops

⚡ Quick fix

  1. Look at the repeating frames in the crash output
  2. Use backing fields for properties
  3. Convert deep recursion to iteration

Detailed fix by platform

C#

  1. csharp
    private string _name = "";
    public string Name { get => _name; set => _name = value; }   // not: get => Name;

How to diagnose

  1. Frames — Which method repeats?
  2. Recursion — Base case present?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.