Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

martin

@wolf359: The debug log does not seem complete. What error do you get? Or what happens? Does it hang on the Session.Open call? I do not see any relation to this topic. Anyway, please upgrade.
wolf359

I'm having a similar problem. It doesn't seem that this was ever resolved. The strange thing about this error is that neither the GetFiles call nor the catch block is ever hit. I attached all 3 logs. Would you mind taking a look?
var options = new SessionOptions
{
    Protocol = Protocol.Sftp,
    HostName = Settings.Default.remoteHost,
    UserName = Settings.Default.username,
    SshPrivateKeyPath = Settings.Default.privateKey,
    GiveUpSecurityAndAcceptAnySshHostKey = true
};
 
var session = new Session();
session.FileTransferProgress += Session_FileTransferProgress;
session.FileTransferred += Session_FileTransferred;
session.DebugLogPath = @"C:\data\debug.log";
session.XmlLogPath = @"C:\data\xml.log";
session.SessionLogPath = @"C:\data\session.log";
 
try
{
    session.Open(options);
    session.GetFiles(Settings.Default.remoteFolder + title, fileInfo.FullName);
}
catch (Exception e)
{
    session.Close();
}
martin

Not sure what that. What I'm basically asking, if you get the exception at the point it is thrown in the WinSCP code, or if you get it outside of WinSCP code. If the first, you probably have enabled breaking on exception throwing. But most (all) instances of that exception will be handled. So you are not interested in those.

Anyway, this should not occur in 5.8.x anymore.
tmcnairbledsoe

I get it from the debug exceptions break list. Not sure if that helps.
martin

How do you catch that exception?

That cannot be an exception caught outside of the .Open call matching the debug log file.

If you take a look at the WinsCP .NET assembly source code, you will that there's try .. catch block around whole method, where the catch block logs an exception, if any. There's no exception in the log.
tmcnairbledsoe


mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string maybeFullPath) Unknown
mscorlib.dll!System.IO.FileStream.Init(string path, System.IO.FileMode mode, System.IO.FileAccess access, int rights, bool useRights, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy, bool useLongPath, bool checkHost) Unknown
mscorlib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) Unknown
mscorlib.dll!System.IO.File.Open(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) Unknown
WinSCPnet.dll!WinSCP.SessionLogReader.OpenLog() Unknown
WinSCPnet.dll!WinSCP.SessionLogReader.DoRead() Unknown
WinSCPnet.dll!WinSCP.SessionLogReader.Read(WinSCP.LogReadFlags flags) Unknown
WinSCPnet.dll!WinSCP.CustomLogReader.TryWaitForNonEmptyElement(string localName, WinSCP.LogReadFlags flags) Unknown
WinSCPnet.dll!WinSCP.CustomLogReader.WaitForNonEmptyElement(string localName, WinSCP.LogReadFlags flags) Unknown
WinSCPnet.dll!WinSCP.Session.Open(WinSCP.SessionOptions sessionOptions) Unknown
> WindowsApplication1.exe!WindowsApplication1.Form1.Button2_Click(Object sender, System.EventArgs e) Line 117 Basic
System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Button.OnClick(System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs mevent) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ButtonBase.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Button.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() Unknown
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[] commandLine) Unknown
martin

The .Open succeeded in this case. Did you still get the error? When? When calling the .PutFiles? Can you post a matching callstack and a log file?

WinSCP .NET assembly can be called from multiple threads. But it will block, when used in parallel.
tmcnairbledsoe

You got it, good call. I've privately attached the log file. As a side question, can WinSCP handle being used by multiple threads?
martin

Do you set it to a path to a directory (wrong) or file (correct)?
tmcnairbledsoe

Any path I pass in to that property throws an unauthorized access exception. Any advice? This is my local machine so I don't see why this should happen. I am admin.
martin

Re: Cannot access the file '...wscp9D6C.00283D6C.tmp' because it is being used by another process

Please attach a full debug log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.DebugLogPath. Submit the log with your post as an attachment. If you do not want to post the log publicly, you can mark the attachment as private.
tmcnairbledsoe

Any assistance? This seems like a simple issue that needs to be resolved.
tmcnairbledsoe

Cannot access the file '...wscp9D6C.00283D6C.tmp' because it is being used by another process

I have seen this error posted before but there does not seem to be a public resolution to the issue. It occurs when opening a connection. Here is the code and a call stack:
Using session As New Session
    session.Open(sessionOptions)
 
    Dim transferOptions As New TransferOptions
    transferOptions.TransferMode = TransferMode.Binary
 
    Parallel.ForEach(imageList, Sub(imagePath)
                                    ProcessWinScp(imagePath, session, transferOptions)
                                End Sub)
End Using

Here is where I initialize session options
Dim sessionOptions As New SessionOptions
With sessionOptions
    .Protocol = Protocol.Ftp
    .HostName = xx
    .UserName = xx
    .Password = xx
End With


mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string maybeFullPath) Unknown
mscorlib.dll!System.IO.FileStream.Init(string path, System.IO.FileMode mode, System.IO.FileAccess access, int rights, bool useRights, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy, bool useLongPath, bool checkHost) Unknown
mscorlib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) Unknown
mscorlib.dll!System.IO.File.Open(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) Unknown
WinSCPnet.dll!WinSCP.SessionLogReader.OpenLog() Unknown
WinSCPnet.dll!WinSCP.SessionLogReader.DoRead() Unknown
WinSCPnet.dll!WinSCP.SessionLogReader.Read(WinSCP.LogReadFlags flags) Unknown
WinSCPnet.dll!WinSCP.CustomLogReader.TryWaitForNonEmptyElement(string localName, WinSCP.LogReadFlags flags) Unknown
WinSCPnet.dll!WinSCP.CustomLogReader.WaitForNonEmptyElement(string localName, WinSCP.LogReadFlags flags) Unknown
WinSCPnet.dll!WinSCP.Session.Open(WinSCP.SessionOptions sessionOptions) Unknown