Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp vnext IServiceCollection exists in two namespaces

Today I created a new empty vnext web project and started to follow this guide: http://www.asp.net/vnext/overview/aspnet-vnext/create-a-web-api-with-mvc-6

When I try to add:

using Microsoft.Framework.DependencyInjection;

and

public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();
    }

I get an error saying:

The type 'IServiceCollection' exists in both 'Microsoft.Framework.DependencyInjection.IServiceCollection, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Microsoft.Framework.DependencyInjection.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

I have been trying different betas of aspnet.mvc and I removed the aspnetcore50 from project.json (as it have solved problems before for me). I also tried to specify the namespace to use but it did not solve anything. Now I am out of ideas on how to solve this.

My project.json

{
"webroot": "wwwroot",
"version": "1.0.0-*",
"exclude": [
    "wwwroot"
],
"packExclude": [
    "node_modules",
    "bower_components",
    "**.kproj",
    "**.user",
    "**.vspscc"
],
"dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta2",
    "Microsoft.AspNet.Mvc": "6.0.0-beta4-12857"
},
"frameworks" : {
    "aspnet50" : { }
}
}

Have anyone got the same error and solved it?

like image 598
user1842278 Avatar asked Feb 24 '15 12:02

user1842278


1 Answers

Why not use explicit reference public void ConfigureServices(Microsoft.Framework.DependencyInjection.IServiceCollection services)

Or Alternatively You may need to use aliases like this

using DI = Microsoft.Framework.DependencyInjection;

then

public void ConfigureServices(DI.IServiceCollection services)
{
    services.AddMvc();
}
like image 78
Bellash Avatar answered Oct 12 '22 21:10

Bellash