ASPNET Core RC2之前的依赖关系含糊不清 [英] ASPNET Core pre-RC2 dependency ambiguity

查看:103
本文介绍了ASPNET Core RC2之前的依赖关系含糊不清的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用:

.NET Command Line Tools (1.0.0-rc2-002439)

Product Information:
Version:     1.0.0-rc2-002439
Commit Sha:  ef0c3b2cee

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.10586
OS Platform: Windows
RID:         win10-x64

并获得:

错误CS0121:以下方法或属性之间的调用不明确:'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action)'和'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions .Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action)'

error CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)' and 'Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.Configure(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action)'

我怀疑"dotnet restore"中包含多个OptionModel程序集(不同版本).

I suspect there are multiple OptionsModel assemblies (different versions) included on "dotnet restore".

证明可能在这里:

第二个建议使用不同的参数名称:

The second suggestion with different parameter name:

Project.lock.json文件有几行有趣的内容("Infrastructure"是引用的程序集):

Project.lock.json file has few interesting lines ("Infrastructure" is a referenced assembly):

"Infrastructure/1.0.0": {
    "type": "project",
    "framework": ".NETFramework,Version=v4.6.1",
    "dependencies": {
      "Domain": "1.0.0",
      "Microsoft.Extensions.Caching.Abstractions": "1.0.0",
      "Microsoft.Extensions.OptionsModel": "1.0.0",
      "Newtonsoft.Json": "8.0.3",
      "WindowsAzure.Storage": "6.2.1"
    },
    "compile": {
      "net461/Infrastructure.dll": {}
    },
    "runtime": {
      "net461/Infrastructure.dll": {}
    }
  }

当Web应用程序使用Microsoft.Extensions.OptionsModel/1.0.0-rc2-15914

while the web application uses Microsoft.Extensions.OptionsModel/1.0.0-rc2-15914

这是基础结构程序集的配置部分:

Here is the configuration section of Infrastructure assembly:

"dependencies": {
    "Domain": "1.0.0-*",
    "Microsoft.Extensions.Caching.Abstractions": "1.0.0-*",
    "Microsoft.Extensions.OptionsModel": "1.0.0-*",
    "Newtonsoft.Json": "8.0.3",
    "WindowsAzure.Storage": "6.2.1-*"
}

问题是:为什么在执行"dotnet restore"时选择了不同的版本(1.0.0和1.0.0-rc2-15914)?

The question is: why different versions (1.0.0 and 1.0.0-rc2-15914) are chosen while executing "dotnet restore"?

更新:我尝试将基础结构项目的project.json更改为"Microsoft.Extensions.OptionsModel":"1.0.0-rc2-15914",但由于屏幕截图中显示的歧义性,我仍然无法编译.是否有任何程序集缓存在我的计算机上的某个地方?

UPDATE: I tried changing project.json of Infrastructure project to "Microsoft.Extensions.OptionsModel": "1.0.0-rc2-15914" but I am still can't compile because of ambiguity displayed in screenshots. Are any assemblies cached somewhere on my computer?

推荐答案

解决方案是:

Microsoft.Extensions.Options 而不是Microsoft.Extensions.OptionsModel包.

Microsoft.Extensions.Options instead of Microsoft.Extensions.OptionsModel package had to be used in a referenced project.

这篇关于ASPNET Core RC2之前的依赖关系含糊不清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆