Click here to Skip to main content
14,362,565 members
Rate this:
Please Sign up or sign in to vote.
See more:
i am doing MVC Application.i Created Model Clss(DinnerRepository.cs, Dinner.cs), Also created Controller Clsaa (DinnerController.cs).And i created two views Not Found.aspx, Details.aspx. while running the Application I am facing this error "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll". plz hlp me
Rate this:
Please Sign up or sign in to vote.

Solution 1

Somewhere in your code, it's become stuck in something like a recursive loop and it will run and run until there is no more stack space available. Poorly named properties can also cause this...

private int _myProperty;
public int MyProperty
    get {return _myProperty;}
    set {MyProperty = value;} // Oops, this will cause Stack overflow...should've been '_myProperty = value'

From what you've posted, it's impossible to say whereabouts this is happening, you need to debug it yourself. Determine where abouts in the application the exception is occurring and put a breakpoint on the controller action you think may be the cause. Step through the code, you should see where a function is being called over and over.
Rate this:
Please Sign up or sign in to vote.

Solution 2

StackOverflowException usually means you've ended up in an infinite recursive loop. If I were in your shoes I'd be looking for where it'd be possible for one of your methods or properties to call itself (or call another method chain which loops back to itself).
Rate this:
Please Sign up or sign in to vote.

Solution 3

This type of exception is actually the easiest to discover under debugger. You should just run the code until exception is caught by the debugger and look at the call stack. (With Visual Studio, you can show the debug windows "Call Stack".) Find at least one method called several times, put a breakpoint on its first statement. Every time your execution stops at the break point, look at the stack. You mean need to shift a break point or add some new ones to get closer to the source of the problem.

You need to find out why recursive never ends and develop a condition of the exit from recursion.

Actually, it's much harder to explain than actually achieve. The process of the debugging always converges, and usually it happens very quickly, if you understand how your code basically works.

Thin July 4-May-12 6:44am
If you instantiate in constructor Class
It will make infinite looping

This is very usual mistake. Perhaps you need to elaborate your answer. What you say is not directly related to mine, where I describe the general method of finding such bugs.
Rate this:
Please Sign up or sign in to vote.

Solution 4

namespace Tenant.DataAccess
    public class TenantOrderDAO : GenericCommon<OrderInfo>
        private OrderInfo mOrderInfo;
        public TenantOrderDAO mTO_DAO { get; set; }

        public OrderInfo OrderInfo
            get { return mOrderInfo; }
            set { mOrderInfo = value; }

        public TenantOrderDAO()
            mOrderInfo = new OrderInfo();
            mTO_DAO = new TenantOrderDAO();

Sandeep Mewara 4-May-12 9:30am
Elaborate please!
Member 13765552 2-Jul-18 10:32am
In my app, i use GMap.NET.WindowsForms version;
when I drap thi control to form, it generate code: this.gmap = new GMap.NET.WindowsForms.GMapControl();

It build susscesstfull, but when run this app, it's have an error:

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

i don't know why. can any one help me sold this error.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100