FTP file download fails on device

Discussion in 'Questions (Windows Mobile)' started by willisgt, Jan 30, 2008.

  1. willisgt

    willisgt Active Member Licensed User

    I've written a routine which dowloads files via the FTP library. In order to preserve the ability to update a progress bar during the download, I use the threading library to create a thread which actually downloads the file.

    All of this works just fine if compiled for the desktop (optimization is on). However, it fails on the device. I'm getting an error message that an optional resource assembly was not found.

    The code for the thread itself is just this simple:
    Sub threadSyncFile_ThreadCode

       ErrorLabel( threadSyncFile_ThreadCodeError )
       ftpSyncFile.GetFile( labelSyncFileSource.Text, labelSyncFileTarget.Text )

       syncSetLastDownload( labelSyncFileSource.Text )

       labelSyncFileTarget.Text   = 


    End Sub
    I've double-checked, and yes, I've got FTPDevice.DLL installed on the device.

    The desktop is running Windows XP Pro; the Basic4PPC version is 6.05; the device is an HTC 8925/AT&T Tilt running Windows Mobile 6.

    I've beaten my head against a wall too many times already this week; anyone have any ideas, especially why this works on the desktop, but not the device?


  2. willisgt

    willisgt Active Member Licensed User

    A little more insight into the problem...

    I commented out these two lines and still got the same error:
    '   ftpSyncFile.GetFile( labelSyncFileSource.Text, labelSyncFileTarget.Text )

    '   syncSetLastDownload( labelSyncFileSource.Text )
    And was able to catch a more robust error message:

    Not Supported Exception
    An error message cannot be displayed because an optional resource assembly containing it cannot be found

    at Microsoft.AGL.Common.MISC.HandleARr()
    at System.Windows.Forms.Form.Close
    at Dbasic.b4p.ShowError()
    at Dbasic.b4p._threadsyncfile_threadcode()
    at Dbasic.b4p._threadsyncfile_threadcode()
    at Threading.Thread.wrapper()

    Last edited: Jan 31, 2008
  3. willisgt

    willisgt Active Member Licensed User

    Answered my own question

    Answer: threads are not GUI-safe.

    Don't try to update anything GUI-related (like the text of a label) from within a thread's code.

  4. agraham

    agraham Expert Licensed User

    It's all documented there in the help and in the comments of the example application. That's why thread events are provided. The example porgram shows a thread updating a textbox using a thread event.

    Edit :-The missing resource assembly contains the actual error messages that would give a bit more detail about the error. So the original error cannot be displayed triggering a further missing resource error! See this thread http://www.basic4ppc.com/forum/showthread.php?t=870
    Last edited: Jan 31, 2008
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice