I wrote a C# class which connects to Dropbox and lets you upload, download, delete and generate link files.
It's working with a Windows Forms but I have to access it from VBA (Microsoft Access). The problem comes when it goes to task.Wait(). I've ""debugged" this throwing Exceptions and after that, doesn't go through.
public DropBox()
{
//Empty constructor because VBA doesn't support constructors with args
}
public void Connect(string tokenUser)
{
try
{
dropbox = new DropboxClient(tokenUser);
var taskInicio = Task.Run(async () => await dropbox.Users.GetCurrentAccountAsync());
//throw new Exception("Arriving?"); //ARRIVES
taskInicio.Wait();
throw new Exception("Arriving?"); //Throws "one or more errors"
}
catch (AggregateException ex)
when (ex.InnerException is BadInputException
|| ex.InnerException is AuthException)
{
throw new Exception("Incorrect Token or without access", ex.InnerException);
}
}
On VBA
Option Compare Database
Private Sub btActivar_Click()
Call test
End Sub
Public Function test()
Dim objDrop As CloudFiles.DropBox
Set objDrop = New CloudFiles.DropBox
MsgBox (objDrop.HolaMundo)
objDrop.Connect("TokenLongChicken")
'objDrop.DeleteFile("https://www.dropbox.com/s...?dl=0")
End Function
The "One or more errors produced" sounds like it comes from the "mscorlib" or so...
Any ideas? This is getting quite messy :/
Thanks.