Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

kinboy9275@...

Element session@0 already read to the end

I'm working with WinSCP from C# in a Windows Service to transfer files between Server and client.

It has been working good for a while.but these days,it goes into an error like
Element session@0 already read to the end


I will post the stack trace below, hope for some clue. I don't have access to the logs now, please help!

System.InvalidOperationException: Element session@0 already read to the end

   在 WinSCP.ElementLogReader.Read(LogReadFlags flags)
   在 WinSCP.SessionElementLogReader.Read(LogReadFlags flags)
   在 WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
   在 WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFlags flags)
   在 WinSCP.Session.GetFiles(String remotePath, String localPath, Boolean remove, TransferOptions options)



the source code as below

public override bool Read(LogReadFlags flags)

        {
            if (_read)
            {
                throw Session.Logger.WriteException(
                    new InvalidOperationException(
                        string.Format(CultureInfo.CurrentCulture, "Element {0} already read to the end", _token)));
            }

            bool result = _parentReader.Read(flags);

            if (result &&
                IsEndElement(_localName) &&
                (Depth == _depth))
            {
                result = false;
                Session.Logger.WriteLineLevel(1, "Element {0} read to the end", _token);
                _read = true;
            }

            return result;
        }


From the source code I can get that this error happened because of the _read was changed to true, but I don't know in what condition can it be changed.