我正在尝试在mvc6中设置一个项目,但是我遇到了这个错误,甚至通过相关主题阅读了几天,我找不到冲突的来源。肯定是一个错过可配置的依赖?
project.json
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
"Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final",
"System.Reflection": "4.1.0-beta-23516",
"System.Xml.XPath.XmlDocument": "4.0.1-beta-23516",
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
"System.Reflection.Extensions": "4.0.1-beta-23516",
"Newtonsoft.Json": "8.0.1-beta3"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.AspNet.Hosting.Abstractions": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final",
"Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
此外,我正在互联网上阅读有关global.json的内容,我在新创建的项目中没有这个内容。如果这是必要的,可能会产生问题?我应该把它放在我的根?它应该包含什么?
最后我的dnvm列表输出:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-beta5 clr x64 win
1.0.0-beta5 clr x86 win
1.0.0-beta5 coreclr x64 win
1.0.0-beta5 coreclr x86 win
* 1.0.0-rc1-update1 clr x86 win default
1.0.0-rc2-16319 clr x86 win
我有大约40个这样的错误:
CS0433 The type 'List<T>' exists in both 'System.Collections, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
CS0433 The type 'Random' exists in both 'System.Runtime.Extensions, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
CS0433 The type 'Dictionary<TKey, TValue>' exists in both 'System.Collections, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
更新1:
感谢oleq的评论我修复了许多依赖性。我的新project.json是:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final"
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
另请参阅我上次评论选项“在构建时生成输出”所引起的问题,但尚未对此进行修复。但总的来说,似乎我的问题是由此选项和错误依赖的组合引起的。