Hi
When ran my code in the emulator and i clicked a button it shows the following error "An unhandled exception of type 'System.StackOverflowException' occurred in Unknown Module."
Kindly help proffer a solution
Thank you inadvance
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 21, 2015, 12:43 PM EST
VulpesRank #55 · 29.2K reputationPosted Jan 21, 2015, 11:29 AM EST
It can also occur if a class definition contains a field with the same type as itself. In such a case the constructor keeps on calling itself until the stack overflows.
However, to diagnose and fix the problem, you need to be able to pinpoint where in your code it's happening. So I'd use the debugger to find out where the error is occurring and, if you can't see anything obvious yourself, post the code here so we can have a look at it.
JOHN JOHNNNYRank #9,451 · 206 reputationPosted Jan 21, 2015, 11:57 AM EST
This is my code below
public partial class BibleInYear
{
public string Date { get; set; }
[JsonProperty("Bible Chapter")]
public string BibleChapter { get; set; }
[JsonProperty("Bible Content")]
public string BibleContent { get; set; }
public override string ToString()
{
string[] props = new string[3];
props[0] = "DATE - " + Date;
props[1] = "Bible Chapter - " + BibleChapter;
props[2] = "Bible Content - " + BibleContent;
return String.Join("\r\n\r\n", props);
}
}
xaml.cs
public partial class BibleInYear : PhoneApplicationPage
{
private List
public BibleInYear()
{
InitializeComponent();
devotions = new List
AddDevotions();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DateTime dt = DateTime.Now;
int month = dt.Month;
int year = dt.Year;
int index;
if (DateTime.IsLeapYear(year) || (month <= 2))
{
index = dt.DayOfYear - 1; // list is indexed from 0
}
else
{
index = dt.DayOfYear; // add a day
}
textblock.Text = devotions[index].ToString(); // or some other property
}
private void AddDevotions()
{
for (int i = 1; i <= 366; i++)
{
string filePath = "MyDevotions/Devotion" + i.ToString() + ".json";
BibleInYear d = ReadJsonFile(filePath);
devotions.Add(d);
}
}
public BibleInYear ReadJsonFile(string JsonfilePath)
{
BibleInYear[] d = null;
using (StreamReader r = new StreamReader(JsonfilePath))
{
string json = r.ReadToEnd();
d = JsonConvert.DeserializeObject
}
return d[0];
}
Await your reply
JOHN JOHNNNYRank #9,451 · 206 reputationPosted Jan 21, 2015, 1:23 PM EST