Discuss (FTP), (FTP on .NET CF) and (FTPS, SFTP and SCP).
no avatar
User

bob43065

Posts

5

Joined

Fri Apr 29, 2011 4:38 am

Location

US

StackOverFlowException at FTPConnection.UploadFile()

by bob43065 » Fri Apr 29, 2011 5:11 am

I just created a small program using edtFTPnet Free and am now doing test uploading using a bunch of small jpeg images (5kB to 15kB each)

After having over 400 some images uploaded, UploadFile() method always fails with "StackOverFlowException in System.dll".

UploadFile() is only called when Uploaded event for previous file transfer process is raised.

Recreating FTPConnection and restarting FTP session before file count reaches 400 does not seem to help at all.

I have no idea what the cause is or where to start to look into this problem.

Please help. Thanks a lot.


Bob
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: StackOverFlowException at FTPConnection.UploadFile()

by support2 » Fri Apr 29, 2011 8:13 pm

You're basically doing event recursion. So like any recursion you eventually run out of stack space.

Just call UploadFile in a loop rather than via the Uploaded event.
no avatar
User

bob43065

Posts

5

Joined

Fri Apr 29, 2011 4:38 am

Location

US

Re: StackOverFlowException at FTPConnection.UploadFile()

by bob43065 » Fri Apr 29, 2011 11:54 pm

Thanks, support2. That solves my problem.

Originally I thought I should use Uploaded handler to check Succeeded before proceeding to the next file.

I'm just wondering: how could a call to UploadFiles() inside Uploaded handler be invoked multiple times (so I had this stack overflow problem)? Uploaded event did not seem to fire multiple times for each UploadFiles(), since my debug message in the handler showed up only once for each UploadFiles() call. Basically, how could it be recursive?

Again, thanks for you help.
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: StackOverFlowException at FTPConnection.UploadFile()

by support2 » Sat Apr 30, 2011 7:38 am

It works like this:

UploadFile
--> Uploaded
------> UploadFile
----------> Uploaded
------------> UploadFile ...

All the variables for each method call go on the call stack, and it eventually runs out of space.

When you don't call UploadFile from Uploaded, it looks like this:

UploadFile
--> Uploaded
UploadFile
--> Uploaded
UploadFile
--> Uploaded

i.e. the call stack is not recursive. Method call variables get freed every time Uploaded completes.

See http://en.wikipedia.org/wiki/Stack_overflow

Who is online

Users browsing this forum: No registered users and 26 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron