将代码移植到 ASP.NET 核心时缺少引用

Missing references when porting code to ASP.NET Core

我在 MVC 项目中使用 DropboxClient 对象并且工作正常,但我需要在 ASP.NET Core 中使用它,当我尝试在中使用完全相同的代码时ASP.NET Core 我遇到了一些编译时错误,这些是错误:

  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'.

我认为所有这些错误都与我需要在 ASP.net Core 中进行的一些配置有关,在 MVC 中,代码 运行s 没有问题。

这是代码:

 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();
        }

我需要在 ASP.net 核心中更改什么才能使此代码变为 运行?

使用包管理器控制台我已经安装了这个包:"Microsoft.NETCore.Portable.Compatibility": "1.0.1" 现在没有错误。 我已经 运行 这个命令:install-package Microsoft.NETCore.Portable.Compatibility。 我正在复制关于这个包的简短描述:

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).