简体   繁体   中英

MVC 6 upgrade in VS 2015RC

I upgraded a VS2015RC MVC 6 web project (DNVM) from beta5 to beta6 and upgraded all dependencies to beta5 that I could. After many tiny tweaks, I am down to one issue, I think. After chasing the configuration changes in startup I found the signature of the Startup method changed and includes an interface that wont resolve.

Error CS0433 The type 'IApplicationEnvironment' exists in both 'Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Microsoft.Framework.Runtime.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' Web.DNX 4.5.1 D:\\Repositories\\Web\\Startup.cs 35

I tried adding with nuget the beta4 Abstractions and Interfaces but neither worked.

What assembly did i miss to upgrade or add to the project?

public Startup(IHostingEnvironment env, **IApplicationEnvironment** appEnv)
        {
            var configuration = new ConfigurationBuilder(appEnv.ApplicationBasePath)
               .AddJsonFile("config.json")
               .AddEnvironmentVariables();

Thanks!

Tracked it down.

Just use "Microsoft.Framework.Runtime.Abstractions": "1.0.0-beta5" in project.json and remove the interfaces dependency if its there.

My 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",

  },

I just got this working myself, the above answer is missing one part about some minor changes also needed to Startup.cs, hopefully this helps others upgrade from beta4 to beta5:

In project.json dependencies add this:

"dependencies": {
    ...
    "Microsoft.Framework.Runtime.Abstractions": "1.0.0-beta5",
    ...
  },

In your Startup.cs make sure you have the following using:

using Microsoft.Framework.Runtime;

The startup method would look like this (including the .Build() at the end which is also needed now.

public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{               
    Configuration = new ConfigurationBuilder(appEnv.ApplicationBasePath)
        .AddJsonFile("config.json")
        .AddEnvironmentVariables()
        .Build();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM