我将VS2015RC MVC 6 Web项目(DNVM)从beta5升级到beta6,并将所有依赖项升级到beta5。经过许多细微的调整后,我想到了一个问题。在启动时追逐配置更改后,我发现Startup方法的签名已更改,并包含一个无法解析的接口。
错误CS0433“Microsoft.Framework.Runtime.Abstractions,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null”和“Microsoft.Framework.Runtime.Interfaces,Version = 1.0”中存在“IApplicationEnvironment”类型。 0.0,Culture = neutral,PublicKeyToken = null'Web.DNX 4.5.1 D:\ Repositories \ Web \ Startup.cs 35
我尝试使用nuget添加beta4抽象和接口,但都没有用。
我错过了哪些程序集升级或添加到项目中?
public Startup(IHostingEnvironment env, **IApplicationEnvironment** appEnv)
{
var configuration = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables();
谢谢!
答案 0 :(得分:2)
跟踪它。
只需在project.json中使用“Microsoft.Framework.Runtime.Abstractions”:“1.0.0-beta5”,并删除接口依赖项(如果有)。
我的project.json
"dependencies": {
"EntityFramework.Commands": "7.0.0-beta5",
"EntityFramework.SqlServer": "7.0.0-beta5",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Google": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
"Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5",
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.SignalR.Server": "3.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5",
"Microsoft.Framework.CommandLineUtils": "1.0.0-beta4",
"Microsoft.Framework.Configuration": "1.0.0-beta5",
"Microsoft.Framework.Configuration.CommandLine": "1.0.0-beta5",
"Microsoft.Framework.Configuration.EnvironmentVariables": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Ini": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5",
"Microsoft.Framework.DependencyInjection": "1.0.0-beta5",
"Microsoft.Framework.Logging": "1.0.0-beta5",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5",
"Microsoft.Framework.Runtime.Abstractions": "1.0.0-beta5",
},
答案 1 :(得分:1)
我刚刚自己开始工作,上面的答案缺少一部分关于Startup.cs也需要的一些小改动,希望这有助于其他人从beta4升级到beta5:
在project.json依赖项中添加:
using Microsoft.Framework.Runtime;
在您的Startup.cs中,请确保使用以下内容:
.Build()
启动方法看起来像这样(包括最后的public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
Configuration = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddEnvironmentVariables()
.Build();
}
,现在也需要。
{{1}}