Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in .NET FTP by (240 points)
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

3 Answers

0 votes
by (162k points)
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.
0 votes
by (240 points)
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.
0 votes
by (162k points)
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

Categories

...