2
votes

I'm using a DropboxClient object in an MVC project and is working fine, but I need to use it in ASP.NET Core, and when I try to use exactly the same code in ASP.NET Core I'm getting some compile time errors, these are the errors:

  1. The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

  2. The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

  3. 'DropboxClient': type used in a using statement must be implicitly convertible to 'System.IDisposable'

  4. The type 'Task<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

  5. The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

I think that all these errors are related to some configuration that I need to do in ASP.net Core, in MVC the code runs without problem.

This is the code:

 public IActionResult Index()
        {
            using (DropboxClient client = new DropboxClient("dddddddddddddsdadffsdf343"))
            {
                var full = client.Users.GetCurrentAccountAsync();
                var result = full.Result.Email;
                var other = full.Result.Country;
                var other2 = full.Result.Name;
            }
                return View();
        }

What do I need to change in ASP.net Core in order for this code to run?

1
Aren't the errors self-explanatory really?walther
You'll need to post your project.jsonuser247702

1 Answers

8
votes

Using package manager console I've installed this package : "Microsoft.NETCore.Portable.Compatibility": "1.0.1" and now there are no errors. I've run this command: install-package Microsoft.NETCore.Portable.Compatibility. I'm copying a short descritpion about this package:

Enables compatiblity with portable libraries targeting previous .NET releases like .NET Framework 4.0 and Silverlight. This package supports retargeting references to classic reference assemblies (mscorlib.dll, system.dll, etc) to new contract assemblies (System.Runtime.dll, System.IO, etc).