Error parsing session log file

Advertisement

lakshmi
Joined:
Posts:
3

Error parsing session log file

We followed the below link while winscp.net implementation by using version 5.7.6(Build 5874).

https://winscp.net/eng/docs/library#csharp

As part of file upload, SessionLogPath is mandatory before open session.

So we start with the following code after Setuping the session options


session.SessionLogPath = @"D:\winScpLog\";
session.Open(sessionOptions);

While executing we got the following error.

Error parsing session log file:

{WinSCP.SessionLocalException: Error parsing session log file ---> System.Xml.XmlException: '', hexadecimal value 0x07, is an invalid character. Line 2, position 62.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Char[] data, Int32 length, Int32 invCharPos)
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at WinSCP.SessionLogReader.DoRead()
--- End of inner exception stack trace ---
at WinSCP.SessionLogReader.DoRead()
at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.Session.Open(SessionOptions sessionOptions)
at WinSCPFileUpload.Form1.BtnUpload_Click(Object sender, EventArgs e)

Please guide us to solve the issue related to file upload task.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,541
Location:
Prague, Czechia

Re: Error parsing session log file

Please attach a full debug log file (Session.DebugLogPath) showing the problem.

You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names. If you do not want to post the log publicly, you can mark the attachment as private or email it to me.

Reply with quote

lakshmi
Joined:
Posts:
3

Re: Error parsing session log file

Thanks for your support.

As par your suggestion,I set the Session.DebugLogPath and checked the application with fallowing code lines.

WinSCP.SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "xxx.xxx.xx.xxx",
UserName = "xxxxxx",
Password = "xxxxxx",
SshHostKeyFingerprint = "ssh-rsa 1536 xx:xx:xx:xxx"
};
using (Session session = new Session())
{
session.SessionLogPath = Server.MapPath("~/Log/logSftp.log");////"your log path";
session.DebugLogPath = Server.MapPath("~/Log/logSftp.log");

session.ExecutablePath = Server.MapPath("~/bin/winscp.exe");
session.DisableVersionCheck = true;
// Connect
session.Open(sessionOptions);

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);

// Throw on any error
transferResult.Check();
}


Even-though I got the same error while calling the statement session.Open(sessionOptions).Kindly provide guide lines how to configure the session related logging information.



[quote="prikryl"]Please attach a full debug log file ([m]Session.DebugLogPath[/m]) showing the problem.

[size=12]You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names. If you do not want to post the log publicly, you can mark the attachment as private or email it to me.[/size][/quote]

Reply with quote

martin
Site Admin
martin avatar

Re: Error parsing session log file

The SessionLogPath and the DebugLogPath must be different.

And mainly, this was not supposed to fix the problem. This was to generate the debug log file, so that you can attach it here for us to investigate.

Reply with quote

lakshmi
Joined:
Posts:
3

Re: Error parsing session log file

I am sending the sample application for your reference.I am unable to store the debug logs.Please provide further steps to upload files.
  • WinSCPExample.zip (4.56 MB, Private file)
Description: Sample application

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Error parsing session log file

We cannot debug your application.

Why are you unable to store the debug logs?

Reply with quote

sushma
Joined:
Posts:
2
Location:
India

Error parsing session log file

Did you get any solution for this?

must we should give the Session log path and Debug log path?

Reply with quote

guest123
Guest

Exception: WinSCP.SessionLocalException: Error parsing session log file

Hi all, I am using WinSCP .net assembly in visual studio obtained via NuGet package manager command: Install-Package WinSCP -Version 5.13.7.0

I am getting the following error when I do in code:
session.Open(sessionOptions);
Any advice on work around would be appreciated:

[2019-02-24 12:22:37.310Z] [0001] Exception: WinSCP.SessionLocalException: Error parsing session log file ---> System.Xml.XmlException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 3, position 3.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParsePI(StringBuilder piInDtdStringBuilder)
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at WinSCP.SessionLogReader.DoRead()
--- End of inner exception stack trace ---
[2019-02-24 12:22:37.310Z] [0001] at WinSCP.Logger.WriteException(Exception e)
at WinSCP.SessionLogReader.DoRead()
at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.SessionElementLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.ReadToEnd(LogReadFlags flags)
at WinSCP.ElementLogReader.Dispose()
at WinSCP.SessionElementLogReader.Dispose()
at WinSCP.Session.Cleanup()
at WinSCP.Session.Open(SessionOptions sessionOptions)
at TestSftpApp.Program.Download1()
at TestSftpApp.Program.Main(String[] args)

Reply with quote

martin
Site Admin
martin avatar

Re: Exception: WinSCP.SessionLocalException: Error parsing session log file

guest123 wrote:

Hi all, I am using WinSCP .net assembly in visual studio obtained via NuGet package manager command: Install-Package WinSCP -Version 5.13.7.0
Please start a new topic for your problem and include a complete session and debug log files.

Reply with quote

Advertisement

You can post new topics in this forum