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

Author Message
tmcnairbledsoe
[View user's profile]

Joined: 2016-06-13
Posts: 6
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:


Code:

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

Code:

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

Advertisements
tmcnairbledsoe
[View user's profile]

Joined: 2016-06-13
Posts: 6
Any assistance? This seems like a simple issue that needs to be resolved.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
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
[View user's profile]

Joined: 2016-06-13
Posts: 6
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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
Do you set it to a path to a directory (wrong) or file (correct)?
tmcnairbledsoe
[View user's profile]

Joined: 2016-06-13
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

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
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
[View user's profile]

Joined: 2016-06-13
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

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
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.
tmcnairbledsoe
[View user's profile]

Joined: 2016-06-13
Posts: 6
I get it from the debug exceptions break list. Not sure if that helps.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
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.
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

Description: (none)

session.log (4.84 KB) Private file

Description: (none)

debug.log (15.63 KB) Private file

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
wolf359 wrote:
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?

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

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License