none
got an error RRS feed

Answers

  • Look at the stack trace for the StackOverflowException. My gut instinsct is that it is your call(s) to `main` which in turn calls back to this function at some point. Hence you recursive keep calling it until it crashes.

    To exit a function when you're done, return from it.


    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, April 11, 2019 5:29 PM
    Moderator
  • A stack overflow occurs when you runt out of stack space. I'm going to assume the overflow is happening because the function that contains the code you posted is recursively calling itself. Use `View details` to look at the stack trace for the exception. You'll see a series of repeating function calls. That is the recursive part and ultimately what is causing the overflow. Step through the recursive calls to ensure you are eventually terminating the app.

    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, April 11, 2019 2:27 PM
    Moderator

All replies

  • There is nothing from the shown code that would cause this issue, how is this code invoked?

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, April 10, 2019 10:23 PM
    Moderator
  • i a trying to chack if there are an a folder and i got this error:


    Hi  Ahron321

    Thank you for posting here. From your description, I have made a sample on my side. The Directory.Exists(String) Method did not cause “System.StackOverflowException” error.

    Can you describe more detailed information/code here, it is beneficial for us to understand your problem and do the test.

    Thank you for your understanding.

    Best Regards

    Yong Lu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 11, 2019 7:13 AM
    Moderator
  • A stack overflow occurs when you runt out of stack space. I'm going to assume the overflow is happening because the function that contains the code you posted is recursively calling itself. Use `View details` to look at the stack trace for the exception. You'll see a series of repeating function calls. That is the recursive part and ultimately what is causing the overflow. Step through the recursive calls to ensure you are eventually terminating the app.

    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, April 11, 2019 2:27 PM
    Moderator
  • All of the code:

            static bool download()
            {
                try
                {
                    if (Directory.Exists("Local"))
                    {
                        if (Directory.GetFiles("Local").Length != 1)
                        {
                            //
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("You have some missing files, Downloading.");
                            Console.ResetColor();
                            //Downloading
                            using (WebClient client = new WebClient())
                            {
                                client.Credentials = new NetworkCredential(u, p);
                                client.DownloadFileCompleted += DownloadCompleted;
                                client.DownloadFileAsync(new Uri("https://qnaclan.000webhostapp.com/SourceCodes/Xsos.zip"), @"Local\Xsos.zip");
                                client.DownloadProgressChanged += (s, e) =>
                                {
                                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                                    Console.WriteLine(e.ProgressPercentage + "%");
                                    Thread.Sleep(800);
                                    Console.ResetColor();
                                };
                                Thread.Sleep(3000);
                                main();
                            }
                        }
                        else
                        {
                            main();
                        }
                    }
                    else
                    {
                        Directory.CreateDirectory("Local");
                        return download();
                    }
                }
                catch
                {
                    Console.WriteLine("lol");
                }
                return true;
            }

    Thursday, April 11, 2019 5:05 PM
  • Look at the stack trace for the StackOverflowException. My gut instinsct is that it is your call(s) to `main` which in turn calls back to this function at some point. Hence you recursive keep calling it until it crashes.

    To exit a function when you're done, return from it.


    Michael Taylor http://www.michaeltaylorp3.net

    Thursday, April 11, 2019 5:29 PM
    Moderator