cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Exception when using ASP.NET Core

Exception when using ASP.NET Core

Dan C.10
Explorer | Level 4

I'm trying to use the Dropbox API with an ASP.NET Core application (v1.1.0). It compiles and resolves all the dependencies when doing a "dotnet restore", but when I call one of the Dropbox API methods, it throws the following exception...

 

An unhandled exception has occurred: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. The system cannot find the file specified. File name: 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' at Dropbox.Api.Files.ListFolderArg..ctor(String path, Boolean recursive, Boolean includeMediaInfo, Boolean includeDeleted, Boolean includeHasExplicitSharedMembers
 at Dropbox.Api.Files.Routes.FilesUserRoutes.ListFolderAsync(String path, Boolean recursive, Boolean includeMediaInfo, Boolean includeDeleted, Boolean includeHasExplicitSharedMembers
 at ******.Core.Respositories.BlogPostDropboxRepository.d__4.MoveNext() in C:\code\******\******.Core\Respositories\BlogPostDropboxRepository.cs:line 31 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
 at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult(
 at ******.Controllers.HomeController.d__2.MoveNext() in C:\code\******\******.Web\Controllers\HomeController.cs:line 18 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted
 at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__20.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
 at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
 at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.d__6.MoveNext()

Looks very similar to this unanswered Stackoverflow question I found when trying to Google for a solution:

 

http://stackoverflow.com/questions/38535571/dropbox-api-throws-filenotfoundexception

 

6 Replies 6

Greg-DB
Dropbox Staff
Thanks for the report! I can't seem to reproduce this issue though. Can you let us know the following so we can look into it?

- What platform/version are you running this on?
- What version of the Dropbox API library do you have installed?
- What's the code that causes this exception?

Thanks in advance!

Greg-DB
Dropbox Staff
Also, please share your project.json. Thanks!

Dan C.10
Explorer | Level 4

Hi. Thank you for your very quick reply!

 

I've found the issue. It was because when I created the project, it had this in the project.json

 

    "frameworks": {
        "netstandard1.6": {
            "imports": "dnxcore50"
        }
    }

 

So that was saying that my assembly targets netstandard 1.6, but the 'imports' bit is telling it to lie to the compiler saying that dependencies targeting dnxcore50 will work. Hence why it compiled, but fell over at runtime.

 

I've fixed the issue by just targeting dnxcore50 instead. 

Dan C.10
Explorer | Level 4

It would be great if Dropbox API targetted the latest dotnet standard though 🙂

Qiming Y.
Dropbox Staff
You can still have your library target .NET standard. The SDK package contains a PCL version which is compatible with .NET standard. What you need to do is change imports from dnxcore50 to portable-net45+win8 and add Microsoft.NETCore.Portable.Compatibility as dependency.

Dan C.10
Explorer | Level 4

Brilliant! This works perfectly. Thanks a lot for your help! 🙂

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Dan C.10 Explorer | Level 4
  • User avatar
    Qiming Y. Dropbox Staff
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?