omobranch.dll中发生了'system.stackoverflowexception'类型的未处理异常 [英] An unhandled exception of type 'system.stackoverflowexception' occurred in omobranch.dll

查看:73
本文介绍了omobranch.dll中发生了'system.stackoverflowexception'类型的未处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using OMOBranch.DAL;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;


namespace OMOBranch.Models
{
    public class Institution
    {
        [Key]
        [Required]
        [Display(Name = "Institution Id")]
        public int IntId { get; set; }
        [Required]
        [Display(Name = "Branch Name", Description = "እባክዎን የቅርጫፍ ስም ያስገቡ")]
        public int BId { get; set; }


        [Required]
        [Display(Name = "Employee Name")]
        public int EmpId { get; set; }
        
        [Required(AllowEmptyStrings = false, ErrorMessage = "ጾታ ባዶ መሆን አይችልም!!!")]
        [Display(Name = "ጾታ ")]
        public ListCreator.SexA SexA { get; set; }
        [Required]
        [Display(Name = "Description")]
        public ListCreator.Description Description{ get; set; }
        [Required]
        [Display(Name = "Institution Type")]
        public ListCreator.InstitutionType InstitutionType{ get; set; }
        [Required]
        [Display(Name = "Weekly Balance")]
        public decimal WeeklyBalance { get; set; }
        [Required]
        [Display(Name = "Previous Balance")]

        public decimal PreviousBalance
        {
            get { return (Cummulative); } 

        }
            
        
     
        [Required]
        [Display(Name = "Cummulative")]
        public decimal Cummulative
        {
            get { return decimal.Add(WeeklyBalance, PreviousBalance); }
        }

        [Required]
        [Display(Name = "ቀን")]
        public DateTime Date { get; set; }
        public virtual Branch branch { get; set; }
        public virtual Employee employee { get; set; }
        

        

        public ApplicationDbContext db = new ApplicationDbContext();
 

    }
}





我的尝试:



是MVC5上的初学者程序员我还没试过



What I have tried:

am the begginner programmer on MVC5 I haven't try

推荐答案

你得到了一个当某些东西进入无限函数调用循环时堆栈溢出,就像这样



You get a stack overflow when something gets into an infinite function call loop, like this

public void MethodA()
{
    MethodA();
}





在上面的MethodA中调用自身,每次发生这种情况时都会在堆栈上保留空间但堆栈是有限的所以最终它会自动调用堆栈空间很多次。



在你的代码中Cummulative调用PreviousBalance调用Cummulative所以如果你尝试访问PreviousBalance你最终在一个无限的调用循环中。



In the above MethodA calls itself and every time this happens it reserves space on the stack but the stack is finite so eventually it calls itself so many times the stack runs out of space.

In your code Cummulative calls PreviousBalance which calls Cummulative so if you try and access PreviousBalance you end up in an infinite call loop.


这篇关于omobranch.dll中发生了'system.stackoverflowexception'类型的未处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆