Post a reply

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

Re: Solved problem with IDisposable

agFinder wrote:

I was getting dozens of WinSCP processes and eventually a 'connection failed' error. Implementing IDisposable in the SCP class then calling .Dispose() after each use solved the problem.

The Session class implements IDisposable:
https://winscp.net/eng/docs/library_session#syntax
Note the use of using in all .NET examples for WinSCP .NET assembly.
One example out of many: https://winscp.net/eng/docs/library#example
agFinder

Solved problem with IDisposable

I was getting dozens of WinSCP processes and eventually a 'connection failed' error. Implementing IDisposable in the SCP class then calling .Dispose() after each use solved the problem.
Rob5624

Hi Prykril,

Thanks for the suggestion... helped me to find the cause for the "ghost"...
I added the "dispose" to the session I used to update data... however I forgot to add it to a second session which I used to check the initial state of a remote folder... :-(
So I added the dispose there as well and now the ghost process also disappears!

(I was able to get 2 log files where I expected to get 3 by adding the microseconds to the logfile)

So issue solved:-)
martin

Please attach a full session 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.
Rob5624

I used the downloaded version 5.7.5 dll and exe
Guest

Yes, I downloaded it earlier this week.
martin

Re: Multiple WinSCP.exe processes

Are you using the latest version of WinSCP .NET assembly?
Rob5624

Finally added the following VB code to find and kill WinSCP.exe processes started by my application:

Imports System.Management

Dim myId = Process.GetCurrentProcess.Id
Dim selectQuery As SelectQuery = New SelectQuery("Win32_Process", "Name = 'WinSCP.exe'")
Dim searcher As New ManagementObjectSearcher(selectQuery)
For Each proc As ManagementObject In searcher.Get
If (proc("ParentProcessId") = myId) And (proc("name") = "WinSCP.exe") Then Process.GetProcessById(proc("ProcessId")).Kill()
Next

Not the most efficient, but it works.
Rob5624

Added the close method to the tool, now only one ghost "WinSCP.exe" remains in memory... still not the solution I look for.
Dispose method results in the same as the close method... every time my application closes a single "WinSCP.exe" process remains in memory, so after ten runs the process is there 10 times...
Rob5624

Multiple WinSCP.exe processes

I created some FTP routine as part of a Visual Basic application that calls WinSCP three times during runtime.
Every time a call to WinSCP is initiated via the WinSCPnet.dll a new "WinSPC.exe" process pops up connected to my application (i.e. as child processes).
I would have expected that a single process would pop up, or at least that every call would re-use the existing process.
What makes things worse is that at the moment my application stops the "WinSCP.exe" processes keeps on running...

Looking for a way to prevent this from happening, I don't like the idea of multiple ghost processes in memory...

Thanks in advance!