We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

Edmara's avatar
Edmara
Explorer | Level 3
9 years ago

TaskCanceledException in call ListFolderAsync("/Image/") with app xamarin portable

Code:

 

var list = await client.Files.ListFolderAsync("/Image/");

 

Error:

 

{System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00031] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess (System.Threading.Tasks.Task task) [0x0001c] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00009] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <1c7d529d87ec4bdcbde02e9494f3b5ae>:0
at Dropbox.Api.DropboxRequestHandler+SendRpcRequestAsync>d__5`3[TRequest,TResponse,TError].MoveNext () [0x000ba] in <392dfbede5b444369f15cf1eb1323eed>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
at POC_DropBox.App+<OnDownloadListaClicked>d__3.MoveNext () [0x00063] in C:\POC\POC_DropBox\POC_DropBox\POC_DropBox\App.cs:62 }

3 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    I can't seem to reproduce this using that code, but a TaskCanceledException can occur of the connection times out. How long does it take before this exception occurs for you? Is there anything that may be interfering with your connection to api.dropboxapi.com?
  • Edmara's avatar
    Edmara
    Explorer | Level 3
    9 years ago

    Below is the code, in project ConsoleApplication works perfectly, but cross platform occurs the error.
    I would like to know if someone has already used the ListFolderAsync api in poject portable (cross platform) with Xamarin Android?

      

    Code:

     

    private async void OnDownloadListaClicked()
    {
    var _accessKey = "<REDACTED>";
    using (DropboxClient client = new DropboxClient(_accessKey))
    {
    //this.ListRootFolder(client);
    try
    {
    bool more = true;
    var list = await client.Files.ListFolderAsync("/Image/");
    while (more)
    {
    foreach (var item in list.Entries.Where(i => i.IsFile))
    {
    // Process the file
    }
    more = list.HasMore;
    if (more)
    {
    list = client.Files.ListFolderContinueAsync(list.Cursor).Result;
    }
    }
    }
    catch (Exception ex)
    {
    // Process the exception
    }
    }
    }

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    I don't know offhand if anyone has used that method in with Xamarin Android. I unfortunately can't offer help with Xamarin in particular, as that's made by a third party. By the way, it looks like Xamarin publishes their own copy of the library, under "Dropbox v2 API for Xamarin" that you may want to try, if you haven't already.

     

     

    Does it take a long time to fail though? That would indicate a timeout.

     

    Also, I redacted it from your post, but for the sake of security, you should disable that access token. You can do so by revoking access to the app entirely, if the access token is for your account, here:

     

    https://www.dropbox.com/account/security

     

    Or, you can disable just this access token using the API:

     

    HTTP: https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke

    .NET SDK: https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_Auth_Routes_AuthUserRoutes_TokenRevokeAsync.htm

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 2 days ago
411 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!