如何修复'System.StackOverflowException?
How to fix 'System.StackOverflowException?
我有一个用 C# NET 3.5 在 WPF 中编写的项目,它开始得很好在调试中。但是,例如,在我的 TemplateColor.cs
class 中,我有这个:
using System;
using System.Windows.Media;
namespace EWIN_THEME_MAKER.ThemeMaker
{
public class TemplateColor
{
private int _id;
private string _name;
private string _toneName;
public int ID
{
get
{
return this._id;
}
set
{
this._id = value;
}
}
public int AllVerticalPos
{
get;
set;
}
public int AllHorizontalPos
{
get;
set;
}
public int HuePageNum
{
get;
set;
}
public int HuePos
{
get;
set;
}
public int TonePaneNum
{
get;
set;
}
public int TonePos
{
get;
set;
}
public string Name
{
get
{
return this._name;
}
set
{
this._name = value;
string[] array = this._name.Split(new char[]
{
'_'
});
this._toneName = array[0];
if (array.Length > 1)
{
this.HuePageNum = int.Parse(array[1]);
}
}
}
public string ToneName
{
get
{
return this._toneName;
}
set
{
this._toneName = value;
}
}
public Color DarkColor
{
get;
set;
}
public Color MainColor
{
get;
set;
}
public Color LightColor
{
get;
set;
}
public Color ShadowColor
{
get;
set;
}
public byte ShadowA
{
get;
set;
}
public Color GrowColor
{
get;
set;
}
public Color TextShadowColor
{
get;
set;
}
public Color TextMainColor
{
get;
set;
}
public Color TextSelectColor
{
get;
set;
}
public double TextShadowPosition
{
get;
set;
}
public Brush DarkColorBrush
{
get
{
return new SolidColorBrush(this.DarkColor);
}
}
public Brush MainColorBrush
{
get
{
return new SolidColorBrush(this.MainColor);
}
}
public Brush LightColorBrush
{
get
{
return new SolidColorBrush(this.LightColor);
}
}
public Brush ShadowColorBrush
{
get
{
return new SolidColorBrush(this.ShadowColor);
}
}
public Brush GrowColorBrush
{
get
{
return new SolidColorBrush(this.GrowColor);
}
}
public Brush TextShadowColorBrush
{
get
{
return new SolidColorBrush(this.TextShadowColor);
}
}
public Brush TextMainColorBrush
{
get
{
return new SolidColorBrush(this.TextMainColor);
}
}
public Brush TextSelectColorBrush
{
get
{
return new SolidColorBrush(this.TextSelectColor);
}
}
public TemplateColor()
{
this.ID = -1;
this.AllVerticalPos = -1;
this.AllHorizontalPos = -1;
this.HuePageNum = -1;
this.HuePos = -1;
this.TonePaneNum = -1;
this.TonePos = -1;
this.Name = "---";
this.DarkColor = default(Color);
this.MainColor = default(Color);
this.LightColor = default(Color);
this.ShadowColor = default(Color);
this.ShadowA = 0;
this.GrowColor = default(Color);
this.TextShadowColor = default(Color);
this.TextMainColor = default(Color);
this.TextSelectColor = default(Color);
this.TextShadowPosition = 0.0;
}
}
}
在此代码中,存在多个此类错误:
An exception of type 'System.WhosebugException
例如我把这部分代码放在那里:
public string Name
{
get
{
return this._name;
}
set
{
this._name = value;
string[] array = this._name.Split(new char[]
{
'_'
});
this._toneName = array[0];
if (array.Length > 1)
{
this.HuePageNum = int.Parse(array[1]);
}
}
}
所以,在这段代码的下一行中有一个无限调用?我不知道如何纠正这个错误。
string[] array = this._name.Split(new char[]
还有...
this.HuePageNum = int.Parse(array[1]);
我们如何预测和纠正这些错误?
我的问题现在已经解决了。
解决方案:Increasing the size of the stack
感谢大家!
我有一个用 C# NET 3.5 在 WPF 中编写的项目,它开始得很好在调试中。但是,例如,在我的 TemplateColor.cs
class 中,我有这个:
using System;
using System.Windows.Media;
namespace EWIN_THEME_MAKER.ThemeMaker
{
public class TemplateColor
{
private int _id;
private string _name;
private string _toneName;
public int ID
{
get
{
return this._id;
}
set
{
this._id = value;
}
}
public int AllVerticalPos
{
get;
set;
}
public int AllHorizontalPos
{
get;
set;
}
public int HuePageNum
{
get;
set;
}
public int HuePos
{
get;
set;
}
public int TonePaneNum
{
get;
set;
}
public int TonePos
{
get;
set;
}
public string Name
{
get
{
return this._name;
}
set
{
this._name = value;
string[] array = this._name.Split(new char[]
{
'_'
});
this._toneName = array[0];
if (array.Length > 1)
{
this.HuePageNum = int.Parse(array[1]);
}
}
}
public string ToneName
{
get
{
return this._toneName;
}
set
{
this._toneName = value;
}
}
public Color DarkColor
{
get;
set;
}
public Color MainColor
{
get;
set;
}
public Color LightColor
{
get;
set;
}
public Color ShadowColor
{
get;
set;
}
public byte ShadowA
{
get;
set;
}
public Color GrowColor
{
get;
set;
}
public Color TextShadowColor
{
get;
set;
}
public Color TextMainColor
{
get;
set;
}
public Color TextSelectColor
{
get;
set;
}
public double TextShadowPosition
{
get;
set;
}
public Brush DarkColorBrush
{
get
{
return new SolidColorBrush(this.DarkColor);
}
}
public Brush MainColorBrush
{
get
{
return new SolidColorBrush(this.MainColor);
}
}
public Brush LightColorBrush
{
get
{
return new SolidColorBrush(this.LightColor);
}
}
public Brush ShadowColorBrush
{
get
{
return new SolidColorBrush(this.ShadowColor);
}
}
public Brush GrowColorBrush
{
get
{
return new SolidColorBrush(this.GrowColor);
}
}
public Brush TextShadowColorBrush
{
get
{
return new SolidColorBrush(this.TextShadowColor);
}
}
public Brush TextMainColorBrush
{
get
{
return new SolidColorBrush(this.TextMainColor);
}
}
public Brush TextSelectColorBrush
{
get
{
return new SolidColorBrush(this.TextSelectColor);
}
}
public TemplateColor()
{
this.ID = -1;
this.AllVerticalPos = -1;
this.AllHorizontalPos = -1;
this.HuePageNum = -1;
this.HuePos = -1;
this.TonePaneNum = -1;
this.TonePos = -1;
this.Name = "---";
this.DarkColor = default(Color);
this.MainColor = default(Color);
this.LightColor = default(Color);
this.ShadowColor = default(Color);
this.ShadowA = 0;
this.GrowColor = default(Color);
this.TextShadowColor = default(Color);
this.TextMainColor = default(Color);
this.TextSelectColor = default(Color);
this.TextShadowPosition = 0.0;
}
}
}
在此代码中,存在多个此类错误:
An exception of type 'System.WhosebugException
例如我把这部分代码放在那里:
public string Name
{
get
{
return this._name;
}
set
{
this._name = value;
string[] array = this._name.Split(new char[]
{
'_'
});
this._toneName = array[0];
if (array.Length > 1)
{
this.HuePageNum = int.Parse(array[1]);
}
}
}
所以,在这段代码的下一行中有一个无限调用?我不知道如何纠正这个错误。
string[] array = this._name.Split(new char[]
还有...
this.HuePageNum = int.Parse(array[1]);
我们如何预测和纠正这些错误?
我的问题现在已经解决了。 解决方案:Increasing the size of the stack
感谢大家!