Reputation: 1
I am in the process of creating an app using C# and Xamarin.Forms, that i am running on my phone through Xamarin Live. It needs to upload and download text files from a specific dropbox folder on my profile on dropbox.com. I have tried several Dropbox libraries already but I have had no success.
Among those I have tried:
The libraries might work (I probably just messed up somewhere), I just feel that the documentation tells me almost all I need to know but then skips out on small things like getting a "dropbox folder path" etc. At this point I basically have no idea how to proceed, so if anyone have any experience with accessing Dropbox, an explanation/clue of how to achieve access to Dropbox from my app would be very much appreciated.
Edit:
Here is what I have tried so far, in accordance with the official dropbox documentation linked above:
namespace test2
{
public class dropboxCallClass
{
public static void Main()
{
var task = Task.Run((Func<Task>)dropboxCallClass.Run);
task.Wait();
}
static async Task Run()
{
using (var dbx = new DropboxClient("myToken"))
{
var data = await dbx.Users.GetCurrentAccountAsync();
if (data != null) {
DisplayTheReturnedValue(data.Name.DisplayName);
} else
{
DisplayTheReturnedValue("call returned null");
}
//Console.WriteLine("{0} - {1}", full.Name.DisplayName, full.Email);
}
}
}
}
I have already created an App on Dropbox, and generated a Token value which I pass to a dropboxClient().
I then call the method by using dropboxCallClass.Main();
What I want to receive from this call, is the name of the dropbox account as a string.
What is returned is an unhandled error exception, on the line Task.Wait():
System.Reflection.TargetInvocationException:
I use Xamarin live to run my App in android. This exception pops up on my phone:
Uncaught Exception Object of type 'NInterpret.interpretedObject' doesn't match the target type 'System.IDisposable'(TargetException)
Edit:
This is the entire exception:
[LogEntry: Time=31/01/2018 16:55:35 +01:00, Level=Error, Title=Uncaught Exception, Message=exception
Parameter name: System.Reflection.TargetException: Object of type 'NInterpret.InterpretedObject' doesn't match target type 'System.IDisposable'
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0004f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at NInterpret.Interpreter.callAMethod (NInterpret.AMethod m, NInterpret.AType[] ptypes, NInterpret.AType[] genericMethodArgs, System.Collections.Generic.Dictionary2[TKey,TValue] genericArgsIndex, System.Object[] args, System.Collections.Generic.List
1[T] byRefArgs, Microsoft.FSharp.Core.FSharpOption1[T] byRefTarget, System.Object target, System.Boolean virtualCall) [0x003f7] in <5a566e1d7eef0f2aa74503831d6e565a>:0
at NInterpret.Interpreter.callMethodReference (System.Collections.Generic.Dictionary
2[TKey,TValue] gargs, Mono.Cecil.MethodReference ms, System.Boolean virtualCall) [0x0037f] in <5a566e1d7eef0f2aa74503831d6e565a>:0
at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption
1[T] lastException) [0x03c6e] in <5a566e1d7eef0f2aa74503831d6e565a>:0
at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption
1[T] lastException) [0x00202] in <5a566e1d7eef0f2aa74503831d6e565a>:0
at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption
1[T] lastException) [0x0013c] in <5a566e1d7eef0f2aa74503831d6e565a>:0 (ArgumentException)]
Upvotes: 0
Views: 1859
Reputation: 7552
If you want to pick files from Dropbox on Android and iOs you can use this binding library from the Dropbox Chooser library:
https://github.com/LMachinery/Plugin.DBChooser
Here is the plugin on the nuget gallery
https://www.nuget.org/packages/Plugin.DBChooser/
If you want to open and save files also from Dropbox the way is more complicated, you should get an access tocken using the Xamarin.Auth Api
https://github.com/xamarin/Xamarin.Auth
After getting the access token you can download files and upload files using the dropbox Api https://www.nuget.org/packages/Dropbox.Api/
Upvotes: 0
Reputation: 1
The issue was not with Dropbox Api itself but with me using Xamarin live. For some reason this prevented me from using any nuget packages or thirdparty dll's.
As such, the solution to making dropbox work, was to enable usb-debugging on in the developer options in the android phone and connect it to the computer via USB-cable.
Upvotes: 0