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

Advertisement

tmcnairbledsoe
Joined:
Posts:
6

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

Reply with quote

Advertisement

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

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.

Reply with quote

Advertisement

tmcnairbledsoe
Joined:
Posts:
6

You got it, good call. I've privately attached the log file. As a side question, can WinSCP handle being used by multiple threads?
  • WinScpLogs.txt (27.13 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar

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.

Reply with quote

tmcnairbledsoe
Joined:
Posts:
6

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
  • WinScpLogs.txt (11.52 KB, Private file)

Reply with quote

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

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.

Reply with quote

Advertisement

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

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.

Reply with quote

wolf359
Guest

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();
}
  • xml.log (158 Bytes, Private file)
  • session.log (4.84 KB, Private file)
  • debug.log (15.63 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar

@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.

Reply with quote

Advertisement

You can post new topics in this forum