Hello Martin,
Thank you very much for your prompt response. FYI, following the guidelines on this website, I was able to properly close and dispose the Sftp session. The issue occurred on someone else's machine who has an EXE without Debug / Session logs enabled. However, sensing the need, I have already enabled the debug / session logs now and they are being generated at my end and should the error occur again, I shall share the logs. Meanwhile, I have used below code to create the debug / session log files:
try
{
dbgLogFile = Path.Combine(dbgLogDir, Process.GetCurrentProcess().ProcessName + "_" + Process.GetCurrentProcess().Id + "_WinSCPDebugLog_" +
DateTime.Now.ToShortDateString().Replace('/', '_') + "_" + DateTime.Now.ToShortTimeString().Replace(':', '_') + ".log");
if (File.Exists(dbgLogFile)) { File.Delete(dbgLogFile); }
session.DebugLogLevel = 2; // need debug logging level understanding as I was unable to find any documentation
session.DebugLogPath = dbgLogFile;
}
catch (IOException e1)
{
// Handle the exception...
session.DebugLogLevel = 0;
session.DebugLogPath = null;
}
catch (UnauthorizedAccessException dbgUAEEx)
{
// Handle the exception...
session.DebugLogLevel = 0;
session.DebugLogPath = null;
}
catch (Exception dbgEx)
{
// Catch and handle any exception
session.DebugLogLevel = 0;
session.DebugLogPath = null;
}
I have put similar code in place for the session and Xml logs as well. Both debug and session logs are being generated, but XML log file is never created. I am not sure what it logs and if and when I would need it. Requesting you to provide more info as to if I would need them and what is the use-case.
I have kept the logs configurable to avoid excessive logging. Still it would be good to know if the above code passes your review and if I can get some understanding of debug log levels. What will happen if I set it to 0? Will the log file be created at all? And what sort of logging is done at different levels?
With regards to do multiple transfers also, I verified by opening multiple instances of our application and initiating the transfers simultaneously. Although the total transfer batch size was not significant, it worked indicating that it is not a hurdle.
However, even with 1 instance of our application running, if I schedule a large file to upload, the application becomes unresponsive. I understand that this is not a issue with WinSCP, but I just want to know whether or not, the solution provided by you would solve the problem? In the link you shared, it is demonstrating opening multiple sessions. In my case, am fine with a single session for now. I am more interested in doing it in a Async fashion or any other fashion that would be non-blocking. Nevertheless, I shall give it a try and report here.
Also, presently I am using
session.Putfiles
method to upload the files to the server. However, if I want to get progress report for large files, is Synchronize the only option I have? I am a little hesitant to use it because I am creating all the instances dynamically and attaching Event Handlers and raising Events becomes super difficult and hence I was avoiding it till this point of time. The problem is creating a
EventArgs
to match the delegate signature using reflection. For that we have to create an in-memory assembly which is huge overhead for a trivial task as this.
Thank you for your assistance so far. I shall update you and other watching this thread if I make some progress on this.
Regards,
Bhushan