.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.
Stack overflow.Process is terminated due to StackOverflowExceptionRepeat 10000 times 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
- Look at the repeating frames in the crash output
- Use backing fields for properties
- Convert deep recursion to iteration
Detailed fix by platform
C#
- csharp
private string _name = ""; public string Name { get => _name; set => _name = value; } // not: get => Name;
How to diagnose
- Frames — Which method repeats?
- 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:
Similar errors
- 0xC0000142 The application was unable to start correctly (0xc0000142)
- attempted to access privacy-sensitive data without a usage description This app has crashed because it attempted to access privacy-sensitive data without a usage description
- Could not cast value of type Swift: Could not cast value of type 'X' to 'Y'
Most viewed in .NET
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- Unable to cast object of type System.InvalidCastException: Unable to cast object of type 'X' to type 'Y'
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 12 Oct 2026