| Dart Home | PowerTCP FTP for .NET | Custom Development | Reply | PowerTCP FTP for .NET Topics | Forums |
| Author | Forum: PowerTCP FTP for .NET Topic: FTP Object occasionally "hangs" on delete |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted March 4, 2008 6:15 AM I have a utility, that connects and downloads a number of files from an FTP server, and then deletes the files. Occasionally it hangs on the Delete Command. I do the delete on handling the Results() array, as follows: Dim f As FtpFile Dim goodcnt As Long goodcnt = Results.GetLength(0) For Each f In Results ' If the exception property is true, display the error message If Not f.Exception Is Nothing Then AddLog("File error (" + f.RemoteFileName + "): " + Replace(f.Exception.Message, vbCrLf, " ")) JobLog(Me._JobName, "#### File error (" + f.RemoteFileName + "): " + Replace(f.Exception.Message, vbCrLf, " ")) goodcnt -= 1 ElseIf f.Count = -1 Then ' If Count is -1, it means that AbortTransfer was called ' before this file started transferring JobLog(Me._JobName, "#### Abort before transfer started.") Aborted = True goodcnt -= 1 ElseIf f.Position <> f.Length Then ' If Position is not equal to length it means that ' AbortTransfer was called while this file was transferring AddLog("Transfer was aborted while storing " + f.LocalFileName) JobLog(Me._JobName, "#### Transfer was aborted while storing " + f.LocalFileName) Aborted = True goodcnt -= 1 Else ' File is transferred. We double-check that it exists locally before we delete it on the server If Dir(f.LocalFileName) <> "" Then ' File exists locally, we can delete it on the server JobLog(Me._JobName, Utility.GetNamePart(f.LocalFileName) & " exists locally and is deleted on the server.") Me.Ftp1.Delete(f.RemoteFileName, False, False) ===> Here it hangs. End If End If Next I know the file is there because I have just downloaded it. I have a suspicion, that the Ftp object for some reason displays an error message box, which I don't see, because this is running as a scheduled task on an unattended server. If this is the case, is there a way to get the Ftp object to dump error messages to a file, or return them in some sort of property/method in stead of just displaying a message box? (AddLog and JobLog are different ways of logging information.) Peter |
| Arjun From: Rome, NY, USA Posts: 137 Member Since: 09/17/07 |
posted March 4, 2008 2:14 PM Hello Peter, I would suggest you to create a trace log of the communication happening and check. To enable tracing, you may use the "Trace event" of the control, to create a trace log (refer help file for more details on this event and a sample code). Have a great day. Regards, Arjun ------ |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted March 4, 2008 3:29 PM Hi Arjun I have already done that. Should have included this in my posting, but here it is: Normally, when it works, I get this logged in my log file: 27-02-2008 03:34:52.171: dummy.fil exists locally and is deleted on the server 27-02-2008 03:34:52.234: ---> TYPE A 27-02-2008 03:34:52.250: <--- 200 Type set to A. 27-02-2008 03:34:52.250: ---> PASV 27-02-2008 03:34:52.265: <--- 227 Entering Passive Mode (87,48,133,187,63,164) 27-02-2008 03:34:52.281: ---> LIST 27-02-2008 03:34:52.296: <--- 150 Data connection accepted from 80.164.230.122:17923; transfer starting. 27-02-2008 03:34:53.593: <--- 226 Transfer ok. 27-02-2008 03:34:53.593: ---> DELE dummy.fil 27-02-2008 03:34:53.609: <--- 250 File "/dummy.fil" deleted. 27-02-2008 03:34:53.609: Succesfully retrieved 1 files. 27-02-2008 03:34:53.609: Succesfully retrieved 1 files. 27-02-2008 03:34:53.609: cmdGet_Click ShowResults Done 27-02-2008 03:34:53.609: Logging out ... 27-02-2008 03:34:53.671: ---> QUIT 27-02-2008 03:34:53.687: <--- 221 Goodbye. 27-02-2008 03:34:54.906: Connection closed 27-02-2008 03:34:54.906: Process complete. But when it hangs, the last thing I get in the log file is: 28-02-2008 01:30:10.906: dummy.fil exists locally and is deleted on the server Peter |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted March 5, 2008 8:34 AM Hi Since I had a suspicion, that my app was displaying a messagebox, I have tried not to kill the task after a specific amount of time, and I have found out that the program stops at the Ftp1.Delete Command displaying the following Exception: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Graphics.FillRectangle(Brush brush, Int32 x, Int32 y, Int32 width, Int32 height) at System.Drawing.Graphics.FillRectangle(Brush brush, Rectangle rect) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle) at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmEraseBkgnd(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmEraseBkgnd(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Peter |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted March 5, 2008 8:36 AM Anyway, as this is an unattended routine, I would like to know if it is possible to send this kind of activity (error messages) to a log file in stead. Peter |
| Arjun From: Rome, NY, USA Posts: 137 Member Since: 09/17/07 |
posted March 5, 2008 10:16 AM Hello Peter, When you say that the application hangs after the Delete command, does the file get deleted from the server? I would also suggest you to try using the latest release and see if the problem occurs. You can get the latest build from the link below: http: |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted March 5, 2008 3:39 PM Hi Arjun It actually hangs during the delete command somewhere, as I see it. And no, the file does not get deleted on the ftp server. |
| Jamie Powell (Admin) From: Rome, NY USA Posts: 448 Member Since: 03/13/07 Extra Support Options Custom Application Development |
posted March 6, 2008 5:21 PM Hello, this request needs to be handled through our administrative procedures prior to response. Please contact sales@dart.com directly about this issue. Thank you. |
| Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted June 12, 2008 11:23 AM This should suppress the message box and record the exception. Ex. Try Me.Ftp1.Delete(f.RemoteFileName, False, False) Catch ex As Exception JobLog(Me._JobName, "#### Error Deleting " & f.RemoteFileName & " From the Server: "+ex.Message) End Try Edit: Forgot to mention that the control itself isn't displaying a messagebox, it looks like that the delete command is failing for some reason and throwing the exception which would generally cause windows to show an error message box to but the windows GDI+ library that is responsible for creating it is flaking out, possibly because it's a service, but I don't know why GID+ is crashing for sure. |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted June 16, 2008 11:52 AM Hi Jason, This unfortunately didn't solve the problem. The GDI+ error still occurs, and in a Windows MessageBox. I too haven't any idea why GDI+ crashes with this error. I have tried moving the application, and have tried on an XP box, a Server2003 box and in a terminal session. No matter what environment, the error still occurs. I will, as my next step, upgrade to the latest version of the Dart.FTP.NET component, to see if that will solve the issue. I have already downloaded it, but before I go ahead and do it, I would like to hear from you, what the best/correct way to do this is, in order not to "break" anything. I am upgrading from 2.3.3.0. Peter |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted June 16, 2008 1:29 PM Hi, Un-install your current version and install the new one. If your project has not picked up the new version, remove the reference and add the new one. You might also try replacing the Delete call with either the Ftp.Delete overload that takes only a filename, or the Ftp.Invoke call with the FtpCommand.Delete parameter, to see if that makes a difference. -ken |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted June 20, 2008 9:33 AM Hi This unfortunately didn't solve the problem. Since the GDI+ error clearly is related to screen updating, and my application is of the unattended type, screen updating is really of no importance to me. I have based my code on the MPut and MGet samples, using these forms. Do you have a working sample of how to code the FTP traffic only, without any screen update? Peter |
| Jason Farrar (Admin) From: Oneida, NY USA Posts: 223 Member Since: 07/24/07 Extra Support Options Custom Application Development |
posted June 25, 2008 12:28 PM The control doe snot updat ethe screen, if the code you posted is all the FTP control code then you are using it without screen updates. The only thing I can really suggest is adding an eventhandler to your application if it's a windows form app, to try and catch the exception. Ex: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AddHandler Application.ThreadException, AddressOf Application_ThreadException End Sub Sub Application_ThreadException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs) If TypeOf (e.Exception) Is System.Runtime.InteropServices.ExternalException Then 'Log error here then return Return End If End Sub |
| pblsoft From: Horsens, Denmark Posts: 8 Member Since: 03/04/08 |
posted July 2, 2008 3:13 AM Hi Seems like I have now found the solution: I hide the form while it is doing it's FTP stuff, and then no GDI+ error happens. Not an optimal solution, but it gets the job done, and nobody is looking at the screen anyway. Any relevant errors are logged in files. Job has run now for 2-3 days without errors. I think that screen update actually happens during ftp work when I am updating the progress bar, handling the progress event, but no reason to use more resources on that now. Peter |
| Reply | PowerTCP FTP for .NET Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|