Tag: 栈溢出

为什么这个递归不会产生StackOverFlowException?

这段代码有什么问题: using System; namespace app1 { static class Program { static int x = 0; static void Main() { fn1(); } static void fn1() { Console.WriteLine(x++); fn1(); } } } 我使用这个命令编译这段代码: csc /warn:0 /out:app4noex.exe app4.cs 当我双击exe时,它似乎没有抛出exception(StackOverFlowException),并且永远保持运行。 使用visual studio命令提示符2010,但我也在系统上安装了vs 2012,这些都是最新的。

C# – entity framework – mscorlib.dll中发生未处理的“System.StackOverflowException”类型exception

mscorlib.dll中发生了未处理的“System.StackOverflowException”类型exception 确保没有无限循环或无限递归。 以下代码在此方法成功时调用: internal static List GetProductsSoldByCompany(Guid CompanyID) { var ret = from a in _dbRiv.ProductsSold where a.Company.CompanyId == CompanyID select a; return ret.ToList(); } 在返回时,它调用实体模型并尝试填充所有外键控对象(子对象)。 架构是[1公司有0到多个ProductsSold]。 出于某种原因,对以下代码的调用只会自行级联: [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute(“RIV_Model”, “FK_ProductsSold_Company”, “Company”)] [global::System.Xml.Serialization.XmlIgnoreAttribute()] [global::System.Xml.Serialization.SoapIgnoreAttribute()] [global::System.Runtime.Serialization.DataMemberAttribute()] public Company Company { get { return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference(“RIV_Model.FK_ProductsSold_Company”, “Company”).Value; } set { ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference(“RIV_Model.FK_ProductsSold_Company”, “Company”).Value = value; } } /// /// There […]