.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
- 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
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y'
Other ways to find it
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026