Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC
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
Posted 20-Mar-12 1:49am
Rate this: bad
good
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...
e.g.
 
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.
  Permalink  
v2
Rate this: bad
good
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.
 
—SA
  Permalink  
Comments
Thin July at 4-May-12 6:44am
   
If you instantiate in constructor Class
It will make infinite looping
 
eg:
SAKryukov at 8-May-12 13:12pm
   
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.
--SA
Rate this: bad
good
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).
  Permalink  
Rate this: bad
good
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();
        }
}
  Permalink  
Comments
Sandeep Mewara at 4-May-12 9:30am
   
Elaborate please!

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

  Print Answers RSS
0 OriginalGriff 445
1 CHill60 410
2 Sergey Alexandrovich Kryukov 354
3 BillWoodruff 190
4 PIEBALDconsult 160


Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 4 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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