Hi, I'm actually in the same problem but when I try to download a file I get "System.ArgumentOutOfRangeException" so the app literally breaks out even when I use try-catch. Does any-one know what is happen?
using (_clienteS3 = new AmazonS3Client("USER", "PASS", RegionEndpoint.USWest2)) { try { var fileCopyName = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, Android.OS.Environment.DirectoryDownloads); TransferUtilityDownloadRequest request = new TransferUtilityDownloadRequest() { BucketName = "BUKET", Key = "FILE.png", FilePath = fileCopyName }; TransferUtility transferUtility = new TransferUtility(_clienteS3); await transferUtility.DownloadAsync(request).ConfigureAwait(false); // here the app breaks-out and throws the exception before it closes (the app) } catch (Exception e) { } //doesn't catch de exception } }
Answers
@kztneda - What does the StackTrace of the ArgumentOutOfRangeException contain? What does the Message of the ArgumentOutOfRangeException contain?
@JohnHardman it says:
"System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
@kztneda - And the stack trace?
Also, you've raised this same question on another thread. Probably best to continue there. See https://forums.xamarin.com/discussion/comment/338226/#Comment_338226
Also, to investigate, have you tried (a) specifying a cancellation token, and (b) not specifying a FilePath?
@JohnHardman i tried with the cancellation token, but if I don't specify the FilePath where is the object been saved?
Trying to work out why you are getting an exception rather than worrying about where the file is saved. One step at a time during debugging.
You'll notice that the apparently working code in the post at https://forums.xamarin.com/discussion/comment/282776/#Comment_282776 does not specify a FilePath.
Also, still interested to see the stack trace from the exception to confirm that the exception is thrown where you think it is.