Hello there, I am having a problem and it is frustrating me because I've been trying to figure it out, and I've even modified the code a few times but the same exception occurs: " 'StackOverflowE xcepton' was unhandled "
Project Details:
Ok, I am creating a text file that will store database information of some customers of mine and I'm using the StreamReader and StreamWriter Class. I can successfully get the information and customer data written to the file, but when I try to retrieve it and store the retrieved data into the listbox I get that exception. I am using a class library/.DLL also in the project, which shouldn't matter because I can call the AddCustomer() function properly. Here's some of the code...
And I call it from the form's button like this;
But there's no error there, Just like to know why it like freezes, and how to fix it. It says "Make sure there is no infinite loop", I don't think I have one though, and it freezes right at the part where I'm declaring the StreamReader in the .DLL
joedeene
Project Details:
Ok, I am creating a text file that will store database information of some customers of mine and I'm using the StreamReader and StreamWriter Class. I can successfully get the information and customer data written to the file, but when I try to retrieve it and store the retrieved data into the listbox I get that exception. I am using a class library/.DLL also in the project, which shouldn't matter because I can call the AddCustomer() function properly. Here's some of the code...
Code:
public string[] retrieveCustomers()
{
System.IO.StreamReader CustomerStreamReader = new System.IO.StreamReader("MyPath"); //This is the line the error is on
int i = 0;
string newLine;
while ((newLine = CustomerStreamReader.ReadLine()) != null)
{
retrieveCustomers().SetValue(newLine, i);
i++;
}
CustomerStreamReader.Close();
return retrieveCustomers();
}
Code:
private void btnReload_Click(object sender, EventArgs e)
{
listBoxCustomers.Items.Clear();
string[] CustomersCollection = papers.retrieveCustomers(); //papers is my .DLL reference.
foreach (string customerInformation in CustomersCollection)
{
listBoxCustomers.Items.Add(customerInformation);
}
}
joedeene
Comment