StackOverflow Exception

  • Nobody/Anonymous


    I am creating merged PDF files from existing documents, and sometimes I get a StackOverflow exception when calling PageManager.Add(Document document) method. I am using C# .NET 3.5. Here is my code snippet:

                    ArrayList sourceFiles = new ArrayList();

                    //store PDF file paths in sourceFiles
                    files::File file = new files::File();
                    Document targetDocument = file.Document;
                    PageManager pm = new PageManager(targetDocument);

                    for (int i = 0; i < sourceFiles.Count; i++)
                        string pdfFile = (string)sourceFiles_;
                        files::File sourceFile = new files::File(pdfFile);
                        pm.Add(sourceFile.Document); //the line where StackOverflowException occurs

                    Serialize(file, targetDocPath);

    Is there any way to work around the exception?


  • Stefano Chizzolini


    the only way to work around this exception is to fix its bug :-)

    Could you please post its stack trace (this way maybe I can spot the issue - there seems to be an infinite recursion somewhere…)?

    You may also try to debug directly from its source code: that's quite a simple task - catch the StackOverflowException from your IDE and walk back through its stack.

  • Nobody/Anonymous


    Thanks for replying!

    Can't catch the stack overflow exception in .NET 2.0 or later, and the only detail I get when the error pops up is this: {Cannot evaluate expression because the current thread is in a stack overflow state.} Is there something else I could try? 


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks